PDA

View Full Version : EditorGridPanel - Column View - pb edition



merovius
11 May 2010, 7:02 AM
Hello,

I've some troubles with EditorGridPanel.

Principles :
- I've an EditorGridPanel with a lot of column and a lot of editors.
- I've a ComboBox with a list of view
- Every time I choose an element in my ComboBox, I hide/show some columns.


Here is the code of my function to change the viewable columns :



/**
* value : the identifier of my new view
* defaultValue : the identifier of the default view
* tabTotal : the table of all view - tabTotal["myView"]={all columns viewable in the view "myView"}
* cm : the columnModel of the grid
* the store of the grid
*/
function setColumnView(value, defaultValue, tabTotal, cm, store) {

//Perf optim.
// the store is temp. saved to reduce the
// function cost
var storeTemp = new Ext.data.Store();
storeTemp.add(store.getRange());
store.removeAll();


//delete all space in the view identifier
var sub = value.indexOf(" ", 0);
if (sub != -1) {
value = value.substr(0, sub);
}

// all columns viewable in the new view
var tab = tabTotal[value];

// temp table
// the i-th column of the column model cm will be viewable
// if boolTab[i] = true
var boolTab = new Array();

// if the new view don't exist, choose the default one
if (!tab) {
tab = tabTotal[defaultValue];
}

if (tab) {
// default : all column viewable
for (i = 0 ; i < cm.getColumnCount() ; ++i) {
boolTab.push(true);
}

// mask all column not vieawable in the new view
for (i = 0 ; i < tab.length ; ++i) {
index = cm.getIndexById(tab[i]);
if (index != -1) {
boolTab[index] = false;
}
}
} else {
for (i = 0 ; i < cm.getColumnCount() ; ++i) {
boolTab.push(false);
}
}

//update of the column model
for (i = 0 ; i < cm.getColumnCount() ; ++i) {
cm.setHidden(i, boolTab[i]);
}

// reload of the original store
store.add(storeTemp.getRange());

// we destroy the temp store
storeTemp.destroy();


}


To enhance the perf, the store (which can have 1000+ items) is temp. saved, deleted and then restored.

This function works perfectly with Ext 2.2.1 but in Ext 3.2.0, every time I change the view, the edition in the grid seems to be blocked :
- unable to ckeck/uncheck checkbox
- we can edit cells, but it does nothing (eg : The old value of a cell is A, we change this value to B => the value displayed after the edition is A.).


Is it a bug in Ext or in my Code ?

merovius
12 May 2010, 7:04 AM
Fix by replacing :


var storeTemp = new Ext.data.Store();
storeTemp.add(store.getRange());
store.removeAll();
by


var storeTemp = store.getRange();
store.removeAll();

and



store.load();
storeTemp.destroy();

by


store.add(storeTemp);