anupkumar
anupkumar

Reputation: 357

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.

Upvotes: 2

Views: 3388

Answers (2)

alexrom7
alexrom7

Reputation: 864

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

Upvotes: 0

RichH
RichH

Reputation: 6138

  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

Upvotes: 1

Related Questions