简体   繁体   English

如何在C#后端中使用EXTJS代理参数?

[英]How to use EXTJS proxy params in C# backend?

I want to use a paging toolbar for my GridPanel. 我想为我的GridPanel使用分页工具栏。

How can I use the params from the store/proxy in the back end? 如何在后端使用商店/代理中的参数?

For example, 例如,

autoLoad: { params: { start: 0, limit: 5} } , 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 http://docs.sencha.com/extjs/4.1.3/#!/api/Ext.data.proxy.Ajax

I have no clue. 我没有任何线索。

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. 当客户端从服务器请求数据时,它将制定一个HTTP请求并将其发送到服务器以接收数据。 The HTTP request URL is generated based on values of start and limit parameters like this: HTTP请求URL是根据startlimit参数的值生成的,如下所示:

/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: 注意:如果您不喜欢名为startlimit参数,则可以将它们重新配置为其他名称:

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. 并且您将分别在后端读取context.Request["startIndex"]context.Request["limitIndex"]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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