PDA

View Full Version : Getting field value from a Store



adibhagra
14 Dec 2009, 11:16 PM
Hey Guys,

I have a store as follows:



kir.store.reviewinfo = new Ext.data.Store({
reader: new Ext.data.JsonReader({
fields: ['iresrv','vdrv','disoutrv','disjustrv','redrqrv','rdjustrv','amapprv','amjustrv'],
root:'rows'
}),
proxy: new Ext.data.HttpProxy({
url:'/kir/index.php/manage/getreviewinfo'
})

});
The JSON returned is as follows:


{success:true,rows:[{"iresrv":"Yes","vdrv":"no","disoutrv":"N\/A","disjustrv":"N\/A","redrqrv":"no","rdjustrv":"N\/A","amapprv":"approved","amjustrv":"CCC"}]}
I need to retrieve the field values from the JSON before the store loads, since i need to check them for some condition.

Like suppose i need to get the value of the field "iresv" from the store, how do i get it?

I think it'll be something like :


store.on('load',function(store){
//code here
});
but i am not sure about the syntax and how to get a particular field value from the store.please help :(

Thanks and regards,

Ice

tubamanu
15 Dec 2009, 12:24 AM
you can try this, or use the event "add" to capture the added record.




for(var a=0;a<YourStore.getCount();a++) {
var row = YourStore.getStore().getAt(a);
alert(row.data.iresrv);
}

adibhagra
15 Dec 2009, 12:42 AM
thanks .. but it says that YourStore.getStore() is not a function

tubamanu
15 Dec 2009, 12:51 AM
yes. i just copied out of a code snippet. my fault.
u can use
kir.store.reviewinfo.getCount() and kir.store.reviewinfo.getAt()

adibhagra
15 Dec 2009, 12:53 AM
yeah i knw that .. firebug says kir.store.reviewinfo.getStore() is not a function

adibhagra
15 Dec 2009, 12:55 AM
okie thanks :)

tubamanu
15 Dec 2009, 12:55 AM
u do not need kir.store.reviewinfo.getStore()

kir.store.reviewinfo.getAt()
kir.store.reviewinfo.getCount()

should work.

adibhagra
15 Dec 2009, 12:59 AM
thanks a lot tubamanu .. that really helped dude

\m/

ice