Author Topic: Remote CRUD with pagination and sorting  (Read 2800 times)

Nisanth

  • Newbie
  • *
  • Posts: 1
    • View Profile
Remote CRUD with pagination and sorting
« on: December 04, 2014, 11:10:16 pm »
Hi,
I have tried to implement CRUD operations with remote pagination and remote sorting. As the URL formation logic in pqGridCrud.js is different from the logic written in pqGrid-min.js pagination and sorting will not work.
Please find my understandings.
To implement remote pagination and sorting we have to implement getURL() method mentioned below
getUrl: function () {
            var sortDir = (this.sortDir == "up") ? "asc" : "desc";
            var sort = ['ShipCountry', 'contactName', 'orderID', 'OrderDate', 'RequiredDate', 'ShippedDate',
                 'ShipVia', 'Freight', 'ShipName', 'ShipAddress', 'ShipCity', 'ShipRegion', 'ShipPostalCode'];
            return { url: "/demos/pagingGetOrders", data: "cur_page=" + this.curPage + "&records_per_page=" +
                this.rPP + "&sortBy=" + sort[this.sortIndx] + "&dir=" + sortDir };
        },

If we are going to integrate the CRUD operations, we cannot use the same the logic mentioned above. As the code written in pgGridCrud.js to form URL override the above logic
   this.options.dataModel.getUrl = function () {
            //debugger;
     return { url: this.url + ((queryStr != null) ? queryStr : "") };
}


Below mentioned code ( in the remoteRequest() function)  forms the pagination URL and make call to server written in  pqGrid-min.js is
   var k=this;var j="";var m="";
               var i=this.options.dataModel;
               if(typeof i.getUrl=="function")
                  {var l=i.getUrl();if(l&&l.url){j=l.url}
                if(l&&l.data){m=l.data}}if(!j

Always data object comes null or undefined and URL will be sending to server without any pagination logic.
In order to achieve this we need to customise URL formation logic in pqGrid.js as well as URL formation logic for the crud operations also in pqGridCrud.js.
Kindly let me know is the any way to handle this situation. Otherwise we have to do customisation in the logic in both files.
Thanks
Nisanth