Monday, 26 March 2012

callback function use in Ext.data.Store


        In ExtJs some application displaying value only at combobox sometime.Because of it take long time fetch label for that value from store .For that we can use setTimeout  function to solve this issue.But it is not proper way to solve this issue.Because time delay  differs based on different browser and browser version.
        Instand of setTimeout function we use "callback" function in "store.load" .This quickly fetch label for that value and displaying label value.

EXAMPLE:
         var testStore = new Ext.data.Store({
                 autoLoad: true,
                proxy: new Ext.data.HttpProxy({
                url: 'applicationURL'}),
                reader: new Ext.data.JsonReader({ root: 'rootElementOfJson'}, [{ name: 'value' }, { name: 'label'}])
     });

testStore.load({
callback: function(rec, options, success) {
Ext.getCmp('comboFieldId').setValue(document.getElementById('fileldId').value);
}

callback function is applicable for only proxy method of store loading

No comments:

Post a Comment