Table load already filtered (server side)

Table load already filtered (server side)

alissonxalissonx Posts: 25Questions: 0Answers: 0
edited April 2014 in General
Hi,

why on load my table... its already filtered?

Showing 1 to 30 of 30 entries (filtered from 2,049 total entries)

and just its showing 30 rows, isnt paginating...

[code]
"bServerSide": true,
"sAjaxSource": "estoque.produtos.ajax.php",
"aaSorting": [[ 1, "asc" ]],
"aoColumnDefs": [ //This identifies column data types to aid sorting.
{"sTitle": "#", "sName": "#", "aTargets": [ 0 ], "bSortable" : false },
{"sTitle": "COD", "sName": "CODIGO", "aTargets": [ 1 ] },
{"sTitle": "DESCRICAO", "sName": "DESCRICAO", "aTargets": [ 2 ] },
{"sTitle": "MARCA", "sName": "CODMARCA", "aTargets": [ 3 ] } ,
{"sTitle": "REF", "sName": "REFERENCIA", "aTargets": [ 4 ] } ,
{"sTitle": "PREÇO VISTA", "sName": "PRECOVENDA", "aTargets": [ 5 ] } ,
{"sTitle": "PREÇO PRAZO", "sName": "PRECOPRAZO", "aTargets": [ 6 ] } ,
{"sTitle": "ESTOQUE DISP.", "sName": "QTDE", "aTargets": [ 7 ], "bSortable" : false }
],

"bDeferRender": true,
"bProcessing": true,
"bInfo": true,
"bPaginate": true,
"sPaginationType": "full_numbers",
"bLengthChange": false,
"bFilter": true,
"bSort": true,
"iDisplayLength": 30,
"bInfo": true,
"bAutoWidth": true
[code]

Replies

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395
    Presumably the answer will be in your data source file: "estoque.produtos.ajax.php"

    (and "Showing 1 to 30 of 30 entries" means there's nothing to paginate).
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Very likely you aren't returning` iTotalRecords` and `iTotalDisplayReocrds` correctly: http://datatables.net/usage/server-side

    Allan
  • alissonxalissonx Posts: 25Questions: 0Answers: 0
    Ok...

    on estoque.produtos.ajax.php

    its returning:

    sEcho":1
    "iTotalRecords":2051
    "iTotalDisplayRecords":30

    i'm trying to show 30 rows by page, with this TOTAL it will give me 69 pages.

    but isnt paginating...

    just appears "first / previous PAGE 1 next / last"

    on my table initialization i'm starting with 30 rows:

    "iDisplayLength": 30,

    but why dont paginate if the total is 2051 and i'm loading all the rows?
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    edited April 2014
    From the documentation page I linked to:

    > iTotalRecords - Total records, before filtering (i.e. the total number of records in the database)

    > iTotalDisplayRecords - Total records, after filtering (i.e. the total number of records after filtering has been applied - not just the number of records being returned in this result set)

    As I said - you aren't returning one of those parameters correctly - in this case `iDisplayLength` .

    Allan
  • PeteBPeteB Posts: 38Questions: 0Answers: 0
    Alison,

    if you are not filtering, then "iTotalDisplayRecords" should have the same value as "iTotalRecords" (i.e. 2051) on the return from Ajax.

    "iDisplayLength" is not returned by Ajax.

    Your code says you are returning 30 records, that is all that will fit on one page, so no need for paging.

    Check your estoque.produtos.ajax.php, it should not need to know the page size.
  • alissonxalissonx Posts: 25Questions: 0Answers: 0
    Look.

    I've changed the code to sLimite for using Firebird DataBase.


    [code]
    if(isset($_GET['sSearch']))
    {
    if($_GET['sSearch']!='' && $_GET['sSearch']!=NULL)
    {

    if($_GET['sSearch']=='')
    {

    if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
    {
    $sLimit = "FIRST ".intval( $_GET['iDisplayLength'] )." SKIP ".
    intval( $_GET['iDisplayStart'] );
    }
    }
    else
    {
    if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
    {
    $sLimit = "FIRST ".intval( $_GET['iDisplayLength'] )." SKIP ".
    intval( $_GET['iDisplayStart'] );
    }

    }
    }
    }
    [/code]

    and now I have this result on the initialization

    iTotalRecords:2051
    iTotalDisplayRecords:2051

    but the table loads 2051 register and don't paginate...
  • alissonxalissonx Posts: 25Questions: 0Answers: 0
    Hello?
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    We'd need a link to the page to be able to understand what is going wrong.

    My only guess at the moment (and its just a guess since I don't have a test link I can check) is that you aren't returning sEcho correctly. It changes on every draw.

    Allan
This discussion has been closed.