Author Topic: Problem with JSON with Remote Sorting  (Read 3606 times)

precator

  • Newbie
  • *
  • Posts: 4
    • View Profile
Problem with JSON with Remote Sorting
« on: October 19, 2013, 12:01:32 am »
I followed the remote sorting example but it doesnt seem to be hitting my Ajax Method. I am using MVC 4.  This is what I have for my code.  GridExample is my Controller and Paging is my ActionResult. Could anyone help me? The grid loads but no data is populating..

return {
                    url: "GridExample/Paging", data: "cur_page=" + this.curPage + "&records_per_page=" +
                        this.rPP + "&sortBy=" + sort[this.sortIndx] + "&dir=" + sortDir
                };


stebe

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Problem with JSON with Remote Sorting
« Reply #1 on: October 24, 2013, 01:02:34 pm »
Hi, can you post more code of your dataModel? I have some options for you to try:

1. Does your actionresult return json?
Code: [Select]
return Json(result, JsonRequestBehavior.AllowGet);
2. Referring to the api:
Code: [Select]
getData: function( dataJSON, textStatus, jqXHR ){
    return { curPage: dataJSON.curPage, totalRecords: dataJSON.totalRecords, data: dataJSON.data };
}

It needs a certain structure to work properly, it needs the current page, total records and your data. When directly accessing your GridExample/Paging method(http://localhost/GridExample/Paging?cur_page=1&records_per_page=10&sortBy=yourColumn&dir=down), do you have a simular structure as http://paramquery.com/demos/pagingGetOrders?cur_page=1&records_per_page=20&sortBy=orderID&dir=asc&_=1364228721972?

Before returning data to your pqGrid by using getData function, you can always use 'console.log(dataJSON)' to check if the JSON object has data. In browser press F12 en go to console to see output. This may be even an easier to read option for checking data than going directly to url.

Please let me know if any of these options worked for you.
« Last Edit: October 24, 2013, 03:51:26 pm by stebe »