I have c开发者_Go百科reated a grid and want to access it when I click on save button in a page. How can I loop the grid object to get its elements and its values?
If you want to get a particular field from each record:
var data = [];
store.each(function(rec){
data.push(rec.get('field'));
});
Here is the answer to my question:
for (var i = 0; i < yourGrid.getStore().data.length; i++) {
var element = Ext.get(yourGrid.getView().getRow(i));
var record = yourGrid.getStore().getAt(i);
alert(record.data.ID);
}
How do you get the rows from the grid?
var rows = grid.getStore().getRange();
rows will be an Array of Record objects.
In order to get DOM of the row you can use following code :
yourGrid.getNode(yourGrid.getStore().getAt(rowIndex))
or you can use getNode directly but incase of any headerbar it may not work as supposed to.
yourGrid.getNode(rowIndex)
This will give you the table row.
精彩评论