4

HI

How to design Nested grids in ExtJS Please provide some samples(How to use RowExpander in ExtJS GridPanel)

2

3 Answers 3

7

Try something like this:

 //Create the Row Expander.
var expander = new Ext.ux.grid.RowExpander({
     tpl : new Ext.Template('<div id="myrow-{Id}" ></div>')
});

//Define the function to be called when the row is expanded.
function expandedRow(obj, record, body, rowIndex){
    //absId parameter for the http request to get the absence details.
    var absId = record.get('Id');

    var dynamicStore = //the new store for the nested grid.

    //Use Id to give each grid a unique identifier. The Id is used in the row expander tpl.
    //and in the grid.render("ID") method.
    var row = "myrow-" + record.get("Id");
    var id2 = "mygrid-" + record.get("Id");  

   //Create the nested grid.         
   var gridX = new Ext.grid.GridPanel({
        store: dynamicStore,
        stripeRows: true,
        columns: [
            //columns
        ],
        height: 120,
        id: id2                  
    });        

    //Render the grid to the row expander template(tpl).
    gridX.render(row);
    gridX.getEl().swallowEvent([ 'mouseover', 'mousedown', 'click', 'dblclick' ]);
}

//Add an expand listener to the Row Expander.
expander.on('expand', expandedRow);

You can find more information on this Here

Sign up to request clarification or add additional context in comments.

Comments

2

How to use RowExpander in grid? Here's an example: http://dev.sencha.com/deploy/dev/examples/grid/grid-plugins.html

More examples can be found from http://dev.sencha.com/deploy/dev/examples/

Comments

1

It is possible to do it as the others have mentioned, however I recommend against it.

Reasons: Memory leaks due to the sub-grids not being destroyed properly. Selection model doesn't work correctly Events get messed up.

2 Comments

Could you provide more insight to those memory leaks?
memory leak occurs, because the grid gets destroyed in the DOM when the grid refreshes, but the attached event handlers etc still exist in JS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.