Data is not retrieved in infragistics iggrid when data binding is called from another page

2.4k views Asked by At

Here is the scenario I am bulding an ASP.NET MVC web application

I have a webpage as page.aspx which contains an infragistics iggrid. It is initialized as

$.ig.loader(function () {

            $("#listingGrid").igGrid({

                primaryKey:"Code",
                autoGenerateColumns: false,
                responseDataKey: "Data.d",
                columns: _data,
                features: [
                {
                  name: "GroupBy",

                },
                {
                    name: 'Paging', pageSize: 10, type: "remote",
                    recordCountKey: "Data.TotalRowCount",
                    pageSizeUrlKey: "pagesize",
                    pageIndexUrlKey: "curpage"
                },
                {
                    name: "Sorting",
                    type: "local"
                },

                {
                    name: "Summaries",
                    type: "local"

                }               
                ]

            });

        });

and i am getting data in this grid on a button click like this

$("#showRecords").click(function () {

        var url = "/Main/Grid?tbname=" + parameter;

        var jsonp = new $.ig.JSONPDataSource({
            dataSource: url, paging: {
                enabled: true, pageSize: 10,
                type: "remote"
            }
        });

        $("#listingGrid").igGrid("dataSourceObject", jsonp).igGrid("dataBind");

    });

this is working fine as it should work

but i i have another page which is child page of page.aspx as search.aspx

in which i am trying to bind data the same way like this

$("#ok").click(function () {
 var url = "/Main/Grid?tbname=" + parameter + "&_query=" + query;

   var jsonp = new $.ig.JSONPDataSource({
       dataSource: url, paging: {
       enabled: true, pageSize: 10,
       type: "remote"
        }
   });

 window.parent.$("#listingGrid").igGrid("dataSourceObject", jsonp).igGrid("dataBind");

});

but the url call is not going to the controller side

here is my contoller

public ActionResult Grid(string tbname, string _query, int pagesize, int curpage)
    {

     res = MvcApplication.dbm.SqlQuery(_query).ToList();

      var jsonDataObj = Json(new
      {
            responseDataKey = "d",
            CurrentRecords=skip+top,
            _skip=skip,
            _top=top,
            TotalRowCount=_totalrowcount,
            d = res
        });

        return Json(res);

 }

For page.aspx the call is going to controller for databinding but for search.aspx its not calling.

Plz help where am I wrong or better way to do it. Thanks in advance

1

There are 1 answers

1
Jason Dean On BEST ANSWER

It looks like your child page is missing the setting for pageIndexUrlKey. By default the DataSource is going to use a key of "page" but since your Controller accepts a property named "curpage" instead you'll have to make sure that key is set whenever you are implementing paging and calling that Controller.