-
17 Aug 2011 4:29 PM #1
Answered: How to get data from GridPanel
Answered: How to get data from GridPanel
Hi All,
I am trying to to get the data from GridPanel. I tried to use grid.getSelections(), but FireBug is complaining that it is not a function.
I am new to EXTJS so if anyone knows how to solve this, please help.
Thanks.
Zalol.
Update:
Apologies. Looks like I made a post in EXTJS 4. Can you please move it from here. I am using EXTJS 3.4Last edited by zalol; 17 Aug 2011 at 5:35 PM. Reason: Wrong section
-
Best Answer Posted by raz0r1
if you only want an array of all data you can use
http://docs.sencha.com/ext-js/4-0/#/...-property-dataCode:grid.getStore().data.items
if you want to search for a specific record(s), you can usee
http://docs.sencha.com/ext-js/4-0/#/api/Ext.util.MixedCollection-method-filterCode:grid.getStore().data.filter(propertyKey, valueToSearchFor);
hope that helps.
-
17 Aug 2011 10:30 PM #2
You have to specify a little:
do you want to get the selected records or do you want to get all records?
If you want to get the selected records, use:
This logs the underlying storerecord of the selected row to your firebug console.Code:var selModel = panel.getSelectionModel(); var selectedRecords = selModel.getSelection(); var selectionCount = selModel.getCount(); for(var i =0;i<selectionCount;i++) { console.log(selectedRecords[i]); }
-
17 Aug 2011 11:17 PM #3
This is really a bit general, but I maybe this helps:
I guess what you are searching is in the view class.Code:grid.getView().getSelectionModel().getSelection()[0] grid.getView().getSelectedRecords()
-
18 Aug 2011 11:03 AM #4
Thanks for the reply guys.
Sorry for not being specific on my question. What I am looking to do is to get all the records from the Grid.
-
18 Aug 2011 5:17 PM #5
So you want all of them, not just the selected ones? The records all live in a store. Essentially the store is 'all the records'. You haven't said exactly what form you want the records in or how you intend to use them. You have several methods available to you on the store, including each() for iterating over them.Sorry for not being specific on my question. What I am looking to do is to get all the records from the Grid.
Code:grid.getStore().each(function(record) { ... });
-
18 Aug 2011 9:50 PM #6
if you only want an array of all data you can use
http://docs.sencha.com/ext-js/4-0/#/...-property-dataCode:grid.getStore().data.items
if you want to search for a specific record(s), you can usee
http://docs.sencha.com/ext-js/4-0/#/api/Ext.util.MixedCollection-method-filterCode:grid.getStore().data.filter(propertyKey, valueToSearchFor);
hope that helps.
-
19 Aug 2011 4:15 AM #7
Depends on your proxy settings.
In case of local memory proxy I use
grid.getStore().getProxy().data
In case of remote proxy you need to retrieve date remotely I guess.
-
26 Feb 2013 2:04 AM #8
ExtJs 4.0.2a
var element_id; // view id of record.
grid.getStore().data.map[element_id].data;


Reply With Quote
