Usually a store loads a list of records, but if you need to load a single record, do this:
var id = 9; //an example record id
var contactsStore = Ext.StoreManager.get('contacts');
contactsStore.load({
id: id, //set the id here
scope:this,
callback: function(records, operation, success){
if(success){
var contact = records[0];
//do something with the contact record
}
}
});
this will send an async request to your server, using the store or its model's proxy, with the read api or its url, something like
/api/contacts/read?id=9
Thanks Neil, this worked for me.
ReplyDeleteI have the following code: onLoadItem application action for my control.
ReplyDelete===========================================================
onLoadItem: function(itemCode) {
var store = Ext.getStore('ItemDetails');
var id = 4;
store.proxy.url = MasterDataManager.globals.url + "Item/" + id;
store.load({
scope : this,
callback : function(records, operation, success){
if (records.length > 0){ // Issue is here: Records returns as NULL
// I can change the following line that not the issue.
var title = Ext.getCmp('titleCommonTitleText').setValue(records);
//this.setActiveRecord(records[0]);
}
}
});
I am pissed off completely. Any help would be highly appreciated. Thanks Mate..