I'm reading about igGrid remote paging here : http://help.infragistics.com/NetAdvantage/jQuery/2013.1/CLR4.0?page=igGrid_Paging.html.
However, it's still unclear to me how I setup my remote paging if I'm NOT using the IG wrappers.
Could someone advise me on how to use recordCountKey and responseDataKey to configure this ? How do I implement my c# page method on the server-side, is it through the grid's "pageIndexChanging" event ?
As per the link above, it says :
"If you are implementing your own remote service (for example in ASP.NET or PHP), in order to properly initialize and render the pager, your service must specify both the responseDataKey (grid option) and the recordCountKey (paging option). The recordCountKey member tells the Paging widget how many records in total are in the backend. The responseDataKey specifies which property in the response contains the resulting data.
Therefore, when remote paging is used, the grid automatically generates the proper request parameters in the following way:
http:///grid/PagingGetData?page=2&pageSize=25"
ex/
$("#imGrid").igGrid({ //dataSource: jsonData,
dataSource: "/Margins/getTrades?level=account&entityName=" + entityName, responseDataKey: "Data.data", columns: [ { headerText: "Member", key: "entityName", dataType: "string", width: "100px" }, { headerText: "Margin", key: "Margin", dataType: "number", format: "double", width: "120px" }, ], features: [ name: "Paging", type: "remote", pageSize: 10,
recordCountKey: "Data.recordCountKey", }
});
and my controller code returns a nice-formatted Json object :
public dynamic getTrades(string entityName, string level = "member") { // Bind to Service (details omitted) BasicHttpBinding httpBinding = new BasicHttpBinding(); // Converts List type to Json format below JavaScriptSerializer ser = new JavaScriptSerializer(); var tradeData = myService.GetTrades(entityName); var jsonDataObj = Json(new { recordCountKey = 50, responseDataKey = "data", data = tradeData }); string jsonData = ser.Serialize(jsonDataObj); return jsonData; }
hey Bob,
yes this sounds perfect, and that's how I think you should do it as a best practice, assuming you aren't relying on our MVC wrappers. By the way, I think it is worth trying with the MVC wrappers, I am sure you will be surprised by how much work they do for you : ) I mean, paging, sorting, filtering, and you don't need to bind to a specific data source type - it's just IQueryable, so you can even pass a list of objects and all those operations I mentioned - paging/sorting/filtering/ etc. - will work out of the box, in any combination.
Let me know how it goes. Thanks,
Angel
oh, and I didn't even have oData set to true. But i suppose that's the oData default as you mentioned, even if not explicitly set to true.
Using std oData, I can't access the parameters in my controller (so I'll stick to your idea re: changing the index keys) :
public dynamic getTrades(string entityName, string level = "member", int skip = 1, int top = 10, string inlinecount="allpages", string pk="tradeId")
{
....
}
GOOD NEWS: So now that I've change pageIndexUrlKey and pageSizeUrlKey, I can clearly see the params to passed into my c# controller.
Key ValueRequest GET /Margins/getTrades?level=account&entityName=0012F&pageIndex=3&pageSize=10&pk=tradeId&_=1373999367405 HTTP/1.1
It's gonna be a bit complicated on the server and/or service side, but not impossible.
As you said, if I know the Total Rec Count, the current Page Index, and the Page Size - then my custom logic should be able to extract the appropriate records from the service.
Does that sound correct from a general perspective ?
thanks.
Ok, i see. yep those are the default ones, that's the default naming in the OData spec. If you need them to be pageIndex or pageSize, you can set it like this:
features: [
name: "Paging",
pageIndexUrlKey: "pageIndex",
pageSizeUrlKey: "pageSize"
]
Thanks,
Actually, yes. I can see the see the additional params getting appended when I use IE F12 tool.
Here's the Request Header:
Key ValueRequest GET /Margins/getTrades?level=account&entityName=0012F&%24skip=0&%24top=25&%24inlinecount=allpages&pk=tradeId&_=1373992748886 HTTP/1.1
So it appears I need different parameter names...
thx
Bob
it should be just "page" not "pageIndex" (this is the default name). Could you let me know if those are sent as part of the request? You can use Firebug or Dev tools for IE to track the request/response.
Thanks