PDA

View Full Version : get a row from a grid



eternasparta
6 Feb 2013, 12:50 AM
I think it's very simple to answer to this question:


I have simple grid with my custom store:



//other code
{xtype: 'grid',
store:'SecondStore',
itemId: 'mainTabPanel2',
columns:[{header: 'Not Form Store', id:'keyId2',}, //this is not from the store
{header: 'From Store', dataIndex: 'label', id:'keyId',}//from the store
]}


the store only populate the second column with id: keyId. In fact it have:


fields: [
{name: 'label'}]


And this work well.


I want to get from a function the row n1 of this grid.



handler: function()
{var grid =Ext.ComponentQuery.query('grid[itemId="mainTabPanel2"]')[0];
//var row= get row(1) <- i don't know how to get the complete row
}


I'm working with ExtJs 4 so i can't get it with the comand
grid.getView().getRow(1);


I can't get it from the store because i want to get also the content of the column with id:keyId2 that is not stored in the store, so I can't do something like:



grid.getStore().getAt(1);


Anyone know how to get the complete row in ExtJs 4?
thank you!

sword-it
6 Feb 2013, 7:22 AM
Hi eternasparta,

You can use getRecords() method of the grid view class, like -


grid.getView().getRecords()[0];

For more detail read the API docs-http://docs.sencha.com/ext-js/4-1/#!/api/Ext.view.Table-method-getRecords

sriram139
6 Feb 2013, 12:38 PM
I think getNode() is what you are looking for.
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.view.Table-method-getNode

Try printing this HTLMElement and you can see complete row element that is rendered.

Thanks,
Sriram

eternasparta
7 Feb 2013, 6:40 AM
thank you!\:D/