tags:

views:

72

answers:

3

Hello,

I have created 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 elemnts and its values ?  
+1  A: 

How do you get the rows from the grid?

var rows = grid.getStore().getRange();

rows will be an Array of Record objects.

BrennaSoft
can i get example of "Record objects" ?
A record is the data behind a row in the grid.
BrennaSoft
A: 

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); }

That's a poor way to do it. See below.
Evan Trimboli
+1  A: 

That's actually quite wrong.

If you want to get a particular field from each record:

var data = [];
store.each(function(rec){
    data.push(rec.get('field'));
});
Evan Trimboli
THX Evan Trimboli anyway