Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ExtJS 4 - grid grouping expand/collpase only certain groups

From the API there is a config flag that one can set to expand or collapse grid groupings when rendered.

Is there a way to only expand the first grouping and have all the others collapsed?

For example i have a store with up to three groupings and would like to always have the first grouping expanded and the others collapsed.

there does not seem to be an easy way from the API to be able to do this!

like image 754
RyanP13 Avatar asked Feb 18 '23 21:02

RyanP13


2 Answers

You have to program it! But it isn't difficult... Look at the official Sencha examples, there you find a grouping example!

You will have to do following:

 //Either this...       
groupingFeature.expand(groupName, true);

//or this...
groupingFeature.collapse(groupName, true);

You should place the commands in an afterrender event of the grid. Or you try the groupchange event from the store (I am not sure if it is called on the init-process)

For the grid it should look like this...

afterrender:( grid, eOpts ) {
    var groupingFeature = grid.getView().features[0];

    groupingFeature.expand(groupName, true);
    ...
}
like image 63
harry Avatar answered Mar 02 '23 18:03

harry


user1934574's answer has a little problem. You should get the view of the grid and then get the features. The code should be :

afterrender:( grid, eOpts ) {
    var groupingFeature = grid.getView().features[0]; 

    groupingFeature.expand(groupName, true);
    ...
}
like image 44
cheftao Avatar answered Mar 02 '23 16:03

cheftao