Home

How to load a single record into a store

Published on 1/12/2012


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

... views