Saturday, October 14, 2017

jQgrid not inserting php returned json data into grid

After return json data from php file , the jQgrid not inserting the json data into the grid , jqgrid built the grid and assigned columns header names , but not the data .
debugging the http response  using firefox developer tools and found the json data syntax is right and no errors there. So what is the problem.

the problem here is that jQgrid requires extra elements in the response other than the real data , which are as follows:

  "page": 2,//current page
    "total": 2,//number of pages
    "records": 11,//# of records in total

So, you have to prepare the json data before sending back to the client to be in the following form:
  
You json should look something like
{
    "page": 2,//current page
    "total": 2,//number of pages
    "records": 11,//# of records in total
    "rows": [//array of data
        {
            "id": "101",//id for this row of data
                "cell": [
                "101",
                "Sundale",
                "OTTP",
                "652",
                "6",
                "65",
                "656665",
                "986346654",
                "823343454",
                "554332"
            ]
        }
    ]
}

No comments:

Post a Comment