PDA

View Full Version : get the all the records in the grid



kamalakarreddy vancha
1 Oct 2013, 10:49 PM
Hi..
i created one grid..i.e editable also.
i need the values of all the records in the grid...
here i giving my code also.
but it is not giving the records..
please give me solution for this ...


var Rec = Ext.getCmp('gridId').getStore();
var recArray = [];
for(var i=0;i<selectedRec.length;i++){
recArray.push(Rec[i].getData());
}
mainGridJsonData = Ext.JSON.encode(recArray);
var finalResult = mainGridJsonData;


Thanks

slemmon
3 Oct 2013, 11:37 AM
I'm not totally sure I'm following what you're wanting to do, yet.

See if the example below is of any help:

https://fiddle.sencha.com/#fiddle/pr



var store = Ext.create('Ext.data.Store', {
storeId:'simpsonsStore',
fields:['name', 'email', 'phone'],
data:{'items':[
{ 'name': 'Lisa', "email":"lisa@simpsons.com", "phone":"555-111-1224" },
{ 'name': 'Bart', "email":"bart@simpsons.com", "phone":"555-222-1234" },
{ 'name': 'Homer', "email":"home@simpsons.com", "phone":"555-222-1244" },
{ 'name': 'Marge', "email":"marge@simpsons.com", "phone":"555-222-1254" }
]},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});


Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{ text: 'Name', dataIndex: 'name' },
{ text: 'Email', dataIndex: 'email', flex: 1 },
{ text: 'Phone', dataIndex: 'phone' }
],
height: 200,
width: 400,
renderTo: Ext.getBody(),
tbar: [{
text: 'Get Record data',
handler: function () {
store.each(function (rec) {
console.log(rec.getData());
});
}
}]
});