Question

I want to use a paging toolbar for my GridPanel.

How can I use the params from the store/proxy in the back end?

For example,

autoLoad: { params: { start: 0, limit: 5} },
autoLoad: {start: 0, limit: 25}

or the params described here :

http://docs.sencha.com/extjs/4.1.3/#!/api/Ext.data.proxy.Ajax

I have no clue.

Was it helpful?

Solution

The documentation link you provided describes it clearly. When the client asks for data from server, it formulates a HTTP request and sends it to server to receive the data. The HTTP request URL is generated based on values of start and limit parameters like this:

/users?start=0&limit=5

On the server you'd read parameters from request:

System.Web.HttpContext context = System.Web.HttpContext.Current;
int start, limit;
if ( int.TryParse(context.Request["start"], out start) &&
    int.TryParse(context.Request["limit"], out limit) )
{
    // send the data to client
}
else
{
    // error handling
}

A side note: If you don't like parameters named start and limit, you can reconfigure them to some other names:

var proxy = new Ext.data.proxy.Ajax({
    url: '/users',
    startParam: 'startIndex',
    limitParam: 'limitIndex'
});

Then the request would look like

/users?startIndex=0&limitIndex=5

and you'd read context.Request["startIndex"] and context.Request["limitIndex"] respectively in the backend.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top