View Full Version : How to hide a column in grid according to the input data

6 Aug 2009, 12:10 AM
Is it possible to hide/show a column in a grid Ext.grid.GridPanel according to the input data?
Is there something like calling a function instead of hidden:true,.I would like to see the value of hidden to be dynamic.


6 Aug 2009, 12:21 AM
The ColumnModel has a method setHidden to change the hidden state.

(you might also be interested in the MetaGrid user extension)

6 Aug 2009, 4:05 AM
Thanks for your reply.I would like to know 2 more things.
1. Is it possible to pass a data other than 'totalcount' and 'root' to Ext.data.JsonStore ?
2. How to hide/show a column by checking the value of that extra data passed ?


6 Aug 2009, 4:13 AM
Something like:

store.on('load', function(){
var data = store.reader.jsonData;
var hidden = data.hidden;
var cm = grid.getColumnModel();
for(var i = 0, len = cm.config.length; i < len; i++){
cm.setHidden(i, hidden[i]);

ps. I would recommend using grid.getColumnModel().setConfig(newConfig) instead to change all columns at once (and don't include unused columns - this is faster than hiding them).

6 Aug 2009, 4:45 AM
thanks a lot...extjs rocksss ..also your support :) ...thanks again