简体   繁体   中英

Custom Paging parameters in Extjs4

In Ext 4, whenever you call

store.loadPage(1)

Ext seems to set the paging parameters start and limit in the request for me.

However I need page and pageSize as the keys for my request parameters. This is how the server handles paging and I have little control over it.

Is there a way I can use such custom paging parameters instead of the default ones provided by Ext?

This is covered in the docs: http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.proxy.Ajax

See pageParam/limitParam/startParam

To prevent a particular param from sending, set the name to undefined.

As Evan answered, but with a concrete example:

Ext.define('MyApp.store.Requests', {
    extend:'Ext.data.Store',
    model:'MyApp.model.Request',
    autoLoad:false,
    remoteSort:true,
    proxy:{
        type:'ajax',
        url:'request/list.json',
        //override default param names
        startParam:"offset",
        limitParam:"max",
        sortParam:"sort",
        simpleSortMode:true, //required for directionParam to be used
        directionParam:"order",
        reader:{
            type:'json',
            root:'data'
        }

    },
    pageSize:25
});

This did the trick for me, added below two params in store's proxy field:

startParam : "startIndex",
limitParam : "limitCount"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM