extjs rowexpander how to expand all

k102 picture k102 · Jul 15, 2011 · Viewed 12.9k times · Source

I'm using Ext.ux.grid.RowExpander

var expander = new Ext.ux.grid.RowExpander({
  tpl : new Ext.Template(
 '<p>{history}</p>'
 )
});

it's used in my grid:

 var grid = new Ext.grid.GridPanel({
        store: store,
        columns: [
            expander,
        ...

Now i want all expander rows to be expanded by deafult.

I'm trying to use expander.expandRow(grid.view.getRow(0)); (i think if i make it, i'll be able to use a for loop :) but i get an error

this.mainBody is undefined @ ***/ext/ext-all.js:11

Please, help me to expand all rows of my grid! Thanks!

Answer

JamesHalsall picture JamesHalsall · Jul 15, 2011

You can do this with a loop, it's quite simple...

for(i = 0; i <= pageSize; i++) {
   expander.expandRow(i);
}

Where pageSize is the number of records per page in your grid. Alternatively you could use the store's count (probably a more scalable solution)...

for(i = 0; i <= grid.getStore().getCount(); i++) {
    expander.expandRow(i);
}