Tuesday, 12 January 2021

jQuery server-side datatable: Sending sorting and searching parameters with sort column name to server-side method.

 Add following code in "ajax" option of server side datatable:

"ajax": {
     "url": "/url",
     "type": "GET",
     "data": function (d,e) {
         var requestData = {
             draw: d.draw,
             length: d.length,
             SortColumn: d.order[0]["column"],
             SortColumnName: e.aoColumns[d.order[0]["column"]].sTitle,
             SortDirection: d.order[0]["dir"],
             length: d.length,
             search: d.search.value,
             start: d.start         
        };
         return requestData;
     },
     "dataSrc": function (json) {
         return json;
     }
}

No comments:

Post a Comment