Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
835
How to implement remote paging in igGrid
posted

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

Parents
  • 24671
    posted

    Hey Bob,

    recordCountKey is a property you need to add to the response data which specifies the total number of records (so that the grid UI knows what to show and how to calculate, i.e. XXX of YYY records, where YYY is the total number of records). responseDataKey is a property holding your array of actual data records. As I see from your example above, those are already properly set. Do you need to add "Data" in front of ".data" and ".recordCountKey", respectively. Could you show me some example response JSON that you're sending to the browser?

    As for the pageSize and page index ("page") parameters, you need to add extra parameters to your service method and read them in its implementation, so that you know which page the client requests. so you need to do something like this :

    var tradeData = myService.GetTrades(entityName, pageSize, pageIndex); // where pageSize and page are parameters that the service will read from the URL, similar to entityName.

    Then you need to modify your GetTrades method to take into account this pageSize and page (the index), in order to return the correct data portion.

    Hope it helps. Thanks,

    Angel 

Reply Children