Paging not working with Ajax datasource.

Paging not working with Ajax datasource.

tpizzotpizzo Posts: 2Questions: 0Answers: 0
edited July 2011 in DataTables 1.8
I am using the datatables jquery plug in version 1.8.1. I have a table with and ajax data source. If I get back for example 20 results and the drop down on the table is set to 10 it still shows all 20 results in the table. If I try changing the drop down selection no change occurs. Below is my JavaScript for creating a data table and the json I am getting back from the web service. The json only has two results to make it easier to read. I also have an alias for jquery hence the $j rather than just $. Can you tell me what I'm doing wrong. Thank you.

Javascript:

$j(document).ready(function () {
CheckListExplorer.ChecklistTable = $j('#ChecklistExplorerTable').dataTable({
"sDom": '<"H"lfr>t<"F"ip>',
"bProcessing": true,
"bServerSide": true,
"bAutoWidth": false,
"sAjaxSource": 'http://localhost/iportal/DesktopModules/ASI.IDoc/BaseControls/Handlers/ChecklistExplorerHandler.ashx',
"aoColumns": [{ "sTitle": "Documents" }, { "sTitle": "ID" }, { "sTitle": "Checklist Name" }, { "sTitle": "Checklist Type" }, { "sTitle": "Account Number" }, { "sTitle": "Account Type"}],
"bJQueryUI": true
}).fnSetFilteringDelay(1500);
});

JSON returned from web service.

{"sEcho":"1","iTotalRecords":2,"iTotalDisplayRecords":"10","iDisplayLength":"10","aaData":[["\u003ca href=\u0027#\u0027 id=\u00274\u0027\u003eDocuments\u003c/a\u003e","4","John C. Customer Home Loan","Auto Converted","",""],["\u003ca href=\u0027#\u0027 id=\u00275\u0027\u003eDocuments\u003c/a\u003e","5","John C. Customer Car Loan","Loan","",""]]}

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    when using bServerSide, you need to do all filtering, limting, sorting in your server side script / web service. DataTables will send parameters to your script (ChecklistExplorerHandler.ashx) but that script needs to do the pagination limits in SQL query or other method.
  • tpizzotpizzo Posts: 2Questions: 0Answers: 0
    edited July 2011
    Why have a iTotalDisplayRecords property if your doing the paging server side.
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    iTotalDisplayRecords is the number of records total, after filtering. it's another stat to give the user and the pagination system. it's not a control mechanism to control the server with, but rather some feedback from the server.

    http://datatables.net/usage/server-side
  • chuchchuch Posts: 1Questions: 0Answers: 0
    Hello every body I really need help with ajax pagination of datatable.
    What I am looking for is :
    datatable with ajax only pagination, but not for search and sorting.
    search and sorting I want as js.
    Is it possible ?
    Please help me out.
    Thank you very much
  • allanallan Posts: 63,597Questions: 1Answers: 10,485 Site admin
    @chuch - please post a link and a debug trace of the table you are having problems with: http://datatables.net/forums/discussion/9719/how-to-ask-for-help

    Allan
This discussion has been closed.