PDA

View Full Version : Grouping Grid, collapse a row by programatic way



krishnaswamy
2 Nov 2010, 9:17 AM
Hi
I am using the grid with grouping view and grouping store. I need to collapse only one particular group and show the rest expanded. how can i do it programatically?

Thanks in advance
Krish

Condor
3 Nov 2010, 5:50 AM
grid.getView().collapseAllGroups();
grid.getView().toggleRowIndex(row, true);
(wait until viewready event fires)

krishnaswamy
4 Nov 2010, 10:29 AM
I am very new to Ext Js and enjoying it, can you please explain more on viewready event?

Condor
4 Nov 2010, 11:17 AM
Is the store already loaded when you create the grid?

If yes, then use:

grid.on('viewready', function(){
...
});

If not, then use:

grid.getStore().on('load', function(){
...
});

krishnaswamy
5 Nov 2010, 7:46 AM
best of Ext JS is this forum, May God bless you Community Support Team!!!

rebeccapeltz
6 Dec 2010, 2:29 PM
Hi,
I'm trying to render the grid with just the first row un-collapsed. I'm only running the collapse code during the load store, but this is before anything has rendered. I tried to handle both the store's 'load' and the grid's 'viewready' events, but the grid's event doesn't fire and the store's event seems premature. Can you help me figure out how to run my collapse code? I'm not even able to get the collapseAllGroups directly from my grid's configuration.

My grid is rendered with a several panels and a viewport.

My store is:




var surgeryStoreGroup =new Ext.data.GroupingStore({

autoDestroy :true,
autoLoad:true,
reader: primarySurgeryReader,
data: data,
groupField:'encounterOrder',
sortInfo:{ field:'encounterOrder', direction:'ASC'},
remoteGroup:false,
listeners:{'load':{fn:function(){collapseAllButFirst();}}}
});




I pulled out the collapseAllButFirst(), so that I could debug it





var collapseAllButFirst = function(){


var grid = Ext.getCmp('IPsurgerygrid');


if (grid != null && grid != 'undefined') {

grid.getView().collapseAllGroups();

grid.getView().toggleRowIndex(0, true);
}









}




I also tried running the collapse at grid's 'viewready'









var grid= surgGridPanelFactoryGroup({




id: encounterType +'surgerygrid',
title:'',
store: surgeryStoreGroup,
expander: surgeryExpander,
listeners:{
'viewready':{fn:function(){collapseAllButFirst();}}


}

});














Is the store already loaded when you create the grid?





If yes, then use:



grid.on('viewready', function(){






...


});






If not, then use:



grid.getStore().on('load', function(){






...



});