Pradeep
Pradeep

Reputation: 418

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?

Upvotes: 1

Views: 4908

Answers (3)

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

startParam : "startIndex",
limitParam : "limitCount"

Upvotes: 0

dbrin
dbrin

Reputation: 15673

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
});

Upvotes: 3

Evan Trimboli
Evan Trimboli

Reputation: 30092

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.

Upvotes: 5

Related Questions