PDA

View Full Version : building the grid column model at run time



ridasfa1
18 Feb 2010, 2:43 AM
Hello,

in one of the forum discussions, the Support member Animal had stated the idea of building
the column model of extjs grid at run time.
I applied this idea where i build the column model on server side and i returned a json string
representing the cofig array that is used to initialize the column model. This array appeared as in the fire bug as follows:
{"cModel":[{"width":160,"header":"Domain Id","dataIndex":"id"},
{"width":160,"header":"Name","dataIndex":"value"}]}
in my grid I am writing:

function getColumnModel() {
return new Ext.grid.ColumnModel(this.myColModel);
}
where this.myColModel is the value of the config array.

but it's not working
Any Help???

p3p3
18 Feb 2010, 6:31 AM
hi,

in my testcase i get from my server NOT the columnmodel obejct, only the array of the header as follow:

[{header: 'Pos.',width:23, sortable.....After this i set the model with
grid.reconfigure(store, new Ext.grid.ColumnModel(strColumnModel));p3p3

ridasfa1
18 Feb 2010, 12:20 PM
Hello,
thanks p3p3, yes only the array should be passed from the server so it worked like this:

[{"width":160,"header":"Domain Id","dataIndex":"id"},
{"width":160,"header":"Name","dataIndex":"value"}]
and it works :)

shailendra
23 Jun 2010, 1:50 AM
[QUOTE=ridasfa1;438548]Hello,
thanks p3p3, yes only the array should be passed from the server so it worked like this:

[{

Condor
23 Jun 2010, 2:39 AM
Only use reconfigure if both the store and the columns change.

If you only want to change the columns then you should use:

grid.getColumnModel().setConfig(newConfig);

Condor
23 Jun 2010, 2:44 AM
If you want to load the everything (fields, data and columns) with one request then you should look at this example (http://www.sencha.com/forum/showthread.php?76406-jsonStore-gt-panel.items&p=371353#post371353).

shailendra
23 Jun 2010, 3:42 AM
[QUOTE=Condor;480007]If you want to load the everything (fields, data and columns) with one request then you should look at [URL=

Condor
23 Jun 2010, 3:50 AM
And what is the problem? Couldn't you write a server application that returns the correct fields+data+columns when you submit the required fields?

shailendra
23 Jun 2010, 4:00 AM
Yes I did thank you
but I used two column model one is the default for the first time and other is when user changes the columns