简体   繁体   中英

How to get values from the store in extjs4

I have a store that fetches data from the zend server. I want to get the store records to do some customizations on my form. For getting data from store i am using the below code.

var index = Ext.StoreMgr.lookup('product.AttributeComboBox').find('abbr',4);
var reco = Ext.StoreMgr.lookup('product.AttributeComboBox').getAt(index);

Above snippet returns no records. Please let me know where i am wrong.

  1. In your debugger check the store exists

    Ext.StoreMgr.lookup('product.AttributeComboBox')

  2. Check how many records are in the store

    Ext.StoreMgr.lookup('product.AttributeComboBox').data.items

  3. Check the records have parsed properly

What came from the server for the record

Ext.StoreMgr.lookup('product.AttributeComboBox').data.items[0].raw

How it get converted into the record

Ext.StoreMgr.lookup('product.AttributeComboBox').data.items[0].data

Can you show us more code ?

So far, seems ok but you will have to check if the store have been created and if it has all the records, just like RichH said.

To check if the Store exists I would do

var productStore = Ext.getStore('product.AttributeComboBox');
console.log(productStore );

To check if the store is loaded

console.log(productStore.getCount());

To find the record

console.log(productStore.findRecord('abbr','4'));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM