Pages

Thursday, April 26, 2012

Modify parameters from ExtJS 3.2 Grid Paging next button

Problem Statement: I have a data store define in ExtJS 3.2 as given below. The problem is when clicking next button in paging bar, the agencyStatus is not passed in.

var agncGridStore = new Ext.data.Store({
    url : '/webui/advertiser/agenciesList.json',
    method : 'GET',
    autoLoad : false,
    reader : new Ext.data.JsonReader({
        root : 'agencies',
        totalProperty : 'agencyCount',
        fields : [ 'id', {
            name : 'name',
            type : 'string',
            sortType : Ext.data.SortTypes.acUCString
        }, 'address', 'status', 'currency' ]
    }),
    listeners : {
        load : function() {
            resizeGridHeight('agncGridID', 200, 300);
        }
    },
    remoteSort : true,
    sortInfo : {
        field : 'name',
        direction : 'asc' | 'desc'
    },
    baseParams : {
        'firstResult' : 0,
        'fetchSize' : pageSize,
        'searchStr' : searchText,
        'agencyStatus' : searchFilter
    }
});
agncGridStore.load();

Problem Solution: After trying different possibilities, finally I got done with the help of beforeload event.
var agncGridStore = new Ext.data.Store({
    url : '/webui/advertiser/agenciesList.json',
    method : 'GET',
    autoLoad : false,
    reader : new Ext.data.JsonReader({
        root : 'agencies',
        totalProperty : 'agencyCount',
        fields : [ 'id', {
            name : 'name',
            type : 'string',
            sortType : Ext.data.SortTypes.acUCString
        }, 'address', 'status', 'currency' ]
    }),
    listeners : {
        load : function() {
            resizeGridHeight('agncGridID', 200, 300);
        },
        beforeload : function(store) {    
            store.baseParams.agencyStatus = searchFilter;
            store.baseParams.searchStr = searchText;
        }
    },
    remoteSort : true,
    sortInfo : {
        field : 'name',
        direction : 'asc' | 'desc'
    },
    baseParams : {
        'firstResult' : 0,
        'fetchSize' : pageSize,
        'searchStr' : searchText,
        'agencyStatus' : searchFilter
    }
});
agncGridStore.load();

No comments:

Post a Comment