PDA

View Full Version : How to get data from Store? (Extjs 4+)



korndeang
30 Apr 2013, 2:02 AM
Dear all,
I facing problem with get store data.
I have create AccountStore and AccountModel class, in AccountStore i used proxy return json data successed.
I would like get data from my store here my sample code

newstore = Ext.getStore('AccountStore');
console.log(newstore);

The result will display as image.
if i want fireld_key
So i must use
newstore.data.items[any index].raw.fied_key ? Or any good trick then this?
I am new in Extjs i am worried by using above is wrong Extjs recommended.

Thanks
Korndeang

43435

Arg0n
30 Apr 2013, 2:06 AM
If you want the field_key you have to itterate to your store(each() (http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.data.Store-method-each)), or use the findRecord() (http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.data.Store-method-findRecord)

If you have the record you can use: record.get('field_key') for getting the value =)

mankz
30 Apr 2013, 2:09 AM
Check out the docs for Store and Model (make sure you've added fields in your model first):

http://docs.sencha.com/extjs/4.1.3/#!/api/Ext.data.Store


newstore.get([any index]).get('your_field_name')