About DataTable's pagination with jquery and json

About DataTable's pagination with jquery and json

abramhumabramhum Posts: 5Questions: 3Answers: 0
edited May 2017 in Free community support

Hi:

dear all, I am a newbie to jQuery DataTables, and I hope to use this package
to build my asp pages. my problem is I hope to get pagination like asp's mechanism
of ObjectDataSource and gridview ,that means the system get one page data each time,
not whole data, and the following code snippet is an idea to add DataTable into
the ajax codes, as below:


function GetDataAndShowInBoostrapTable() { $("#btnChecking").click(function () { $.ajax({ type: 'POST', dataType: "json", //for post method url: './../JSON_TESTING/jQuery_Json_Table.aspx/GetEmployee', contentType: 'application/json; charset=utf-8', data: JSON.stringify({ empId: 1, pagenum:2, limit:10}), success: function (response) { var arr = JSON.parse(response.d); $('#lblData').text(arr.EmpAge); ///here will be insert DataTable function in future }, error: function (error) { alert(error); } }); return false; }); }

I hope to pass the page number and limit to the function GetEmployee via ajax and json,
and when the data will back to the page after server processing, it can then be turned into
DataTables format. Is any one know how to do that, thanks a lot.

Answers

  • allanallan Posts: 61,822Questions: 1Answers: 10,129 Site admin

    The DataTables server-side processing (i.e. data for one page at a time) data interchange requirements are documented here. It lists the parameters that DataTables requires to be able to do the one-page-at-a-time approach.

    Allan

This discussion has been closed.