show different item on selectionchange on a grid

Armance picture Armance · Jun 23, 2011 · Viewed 11.8k times · Source

i have a grid and a form, i need to show different items on the form each time we select a row on that grid

i ve been looking on how to do this, and found

    Ext.getCmp('myform').hide() // or  .show()

and

    listeners: { selectionchange: function () {...}

now i dont know which row is selected so i can specify which item to show

thanks

Answer

Netzpirat picture Netzpirat · Jun 23, 2011

You get the selected rows as second parameter in the selectionchange event handler:

listeners: {
    selectionchange: function (view, selections, options) {
        console.log(view, selections, options);
    }
}

So the first selected row is the first element in the selections array:

record = selections[0]

This is described in the Ext JS 4 API documentation for the selectionchange event.