jquery datatables only can get 10 records?

jquery datatables only can get 10 records?

matt.crawfoordmatt.crawfoord Posts: 31Questions: 13Answers: 0
edited July 2016 in Free community support

I have a very large dataset (maybe more than million rows) that I would like to have be scrollable on an HTML page(like https://datatables.net/extensions/scroller/examples/initialisation/server-side_processing.html).
I am developing a web application . I have a table implemented using Data Table. I am performing my search and sort using server side code . Initially I am fetching 10 records. All these were working fine.
but when i the other page data are all the same , it's seems like only get 10 records from server side .
but iTotalDisplayRecords is not only 10 ,it's more than 10 and it's correct .
total records img what's problem with this ?

Currently my code is ,

datatable.php :

var table = $('#example').DataTable( {
"processing": true,
 "serverSide": true,
    "ajax": {
       url: "process.php",
       type: 'POST',
                data: {
                   from: "<?php echo $from; ?>",
                   to: "<?php echo $to; ?>"
                      }
     },
    "columns": [
        {
            "className":      'details-control',
            "orderable":      false,
            "data":           null,
            "defaultContent": ''
        },
        { "data": "timestamp"},
        { "data": "message"}
    }

         ], 

} );

<br>
process.php(server side ) :

 $qryurl ='<url:port>/log-*/_search?size=10'  ;
 //every page get the same data (10 records)

  if ( isset( $_POST['iDisplayStart'] ) && $_POST['iDisplayLength'] != '-1' )
    {
        //it's looks like didn't in ???
      $qryurl =$qryurl.'&from='.$_REQUEST['iDisplayStart']; 

    }

 .......
//json output 
 $results = array(
 "sEcho" => intval($_POST['sEcho']),
 "draw"  => intval($_POST['draw']),
 "iTotalRecords" =>intval($total),
 "iTotalDisplayRecords" => intval($total),
  "aaData"=>$sourceary
        );

I tried few logics but it didn't worked for me. From this code how I have to proceed.
Any help will be appreciated !!

Answers

  • allanallan Posts: 61,743Questions: 1Answers: 10,111 Site admin

    This page details the options that should be returned by the server-side.

    The parameters your code above uses are the legacy parameters and will not be used unless you invoke the legacy mode (I'd suggest against it - just update your parameters).

    If that doesn't work, I'd need a link to a page showing the issue.

    Allan

  • matt.crawfoordmatt.crawfoord Posts: 31Questions: 13Answers: 0
    edited July 2016

    Do you mean update the json output parameters ? How to update parameters ? I am new to Datatables ,can you give me an example ?

  • allanallan Posts: 61,743Questions: 1Answers: 10,111 Site admin

    Do you mean update the json output parameters ? How to update parameters ?

    Just change the names in your code. The page I linked to above gives the details of what DataTables expects in the return. For example change iTotalRecords in your code to be recordsTotal.

    Allan

This discussion has been closed.