[1.7.2 ver] Pagination not work

[1.7.2 ver] Pagination not work

pakypaky Posts: 106Questions: 0Answers: 0
edited September 2010 in Bug reports
Hi Allan, I use last release (1.7.2) my table is server-side

[code]
dataTableEventi=$('#tab_eventi').dataTable
({
"bAutoWidth": false,
"sDom": '<"add_button_eventi">flrtip',
"aoColumns":
[
/*field1*/ {"bVisible":false},
/*field2*/ {"sWidth": "3%","bSortable":true},
/*field3*/ {"sWidth": "10%","bSortable":true},
/*field4*/ {"sWidth": "10%","bSortable":true},
/*field5*/ {"sWidth": "10%","bSortable":false},
/*field6*/ {"sWidth": "20%","bSortable":true},
/*field7*/ {"sWidth": "20%","bSortable":false},
/*field8*/ {"sWidth": "27%","bSortable": false}
],
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "__files/eventi/server_processing_table_eventi.php",
// Aggiunta della variabile di sessione
"fnServerData": function ( sSource, aoData, fnCallback ) {
aoData.push( { "name": "session_id", "value": <?php echo $_SESSION['user_id'];?> });
aoData.push( { "name": "rnd", "value": rnd_cache_damn });
$.ajax( {
"dataType": 'json',
"type": "GET",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
},


//salva nei cookies le scelte
"bStateSave": true,
"bJQueryUI": false,
"sPaginationType": "full_numbers",
"oLanguage":
{
"sLengthMenu": "Mostra _MENU_ righe per pagina",
"sZeroRecords": "Nessun evento",
"sSearch":"Trova evento",
"sInfo": "Dal _START_^ al _END_^ su un totale di _TOTAL_ eventi",
"sInfoEmtpy": "0 to 0 of 0 prodotti",
"sInfoFiltered": "( su _MAX_ totali)"
},

"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull )
{
$(nRow).addClass(aData[0]);
return nRow;
}
});
[/code]

.... pagination number are dead ... nothing happens if I click on "Next" or "Last" button :( why ?

thanks for all.

Replies

  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin
    What does your json return from the server look like?

    Allan
  • pakypaky Posts: 106Questions: 0Answers: 0
    In DataTable_info (div) show this text :

    [from 1 to 10 on total of 10] Total=11

    But don't move it on second page for show 11^ record ...
  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin
    Without seeing the json I can't be sure, but I'd guess that your return for these two parameters is incorrect:

    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)

    With 11 rows to be display and no filter applied, they should both be 11.

    Allan
  • pakypaky Posts: 106Questions: 0Answers: 0
    Ok here json returned, (I try it on JsonLint all is ok)

    [code]
    {
    "sEcho": 1,
    "iTotalRecords": 11,
    "iTotalDisplayRecords": 10,
    "aaData": [
    [
    "scaduto",
    "201",
    "28/04/2010",
    "03/05/2010",
    "06",
    "Equipaggio ...",
    "divisione spese",
    "elimina"
    ],
    [
    "scaduto",
    "206",
    "21/03/2010",
    "21/03/2010",
    "01",
    "Cerchiamo u...",
    "gratis",
    "elimina"
    ],
    [
    "scaduto",
    "244",
    "20/06/2010",
    "20/06/2010",
    "01",
    "velaggiata ...",
    "gratis",
    "elimina"
    ],
    [
    "incorso",
    "253",
    "13/08/2010",
    "03/11/2010",
    "24",
    "Ospitiamo p...",
    "cambusa costo fisso",
    "elimina"
    ],
    [
    "",
    "264",
    "28/09/2010",
    "30/09/2010",
    "03",
    "YOAHOOOO...",
    "cambusa costo fisso",
    "elimina"
    ],
    [
    "",
    "265",
    "28/09/2010",
    "30/09/2010",
    "03",
    "YOAHOOOO...",
    "cambusa costo fisso",
    "elimina"
    ],
    [
    "",
    "266",
    "28/09/2010",
    "30/09/2010",
    "03",
    "YOAHOOOO...",
    "cambusa costo fisso",
    "elimina"
    ],
    [
    "",
    "267",
    "28/09/2010",
    "30/09/2010",
    "03",
    "YOAHOOOO2...",
    "cambusa costo fisso",
    "elimina"
    ],
    [
    "",
    "268",
    "28/09/2010",
    "30/09/2010",
    "03",
    "YOAH3...",
    "camsa fisso",
    "elimina"
    ],
    [
    "",
    "270",
    "28/09/2010",
    "30/09/2010",
    "03",
    "YOAH5...",
    "camsa fisso",
    "elimina"
    ]
    ]
    }
    [/code]
  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin
    iTotalDisplayRecords looks suspect. I think it should be 11. As per the documentation:

    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)

    You don't need to tell it the length of the aaData array, since DataTables can just do aaData.length... :-)

    Allan
  • pakypaky Posts: 106Questions: 0Answers: 0
    Can fnRowCallback function upset him ?! You say that iTotalDisplayRecords must equal 11?
  • pakypaky Posts: 106Questions: 0Answers: 0
    If I change *iDisplayLength* param with select from 10 to 25 rows ... it show more then 10 rows ... but pagination don't work :(

    That there is some bug in dataTable 1.7.2 ? The code is always the same one used in an earlier version ...

    bye
  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin
    I'm not aware of any bug in DataTables 1.7.2 in this area - and as can be see, server-side processing appears to be working fine: http://datatables.net/examples/server_side/server_side.html . It also passed the unit tests before release (although it's not full proof it's a good indication).

    Can you post a link to an example which isn't working please.

    Did you correct the issue with iTotalDisplayRecords (i.e. it should be 11 if there are 11 records in the data set with no filtering and no pagination)?

    Allan
  • pakypaky Posts: 106Questions: 0Answers: 0
    Allan write:
    Did you correct the issue with iTotalDisplayRecords (i.e. it should be 11 if there are 11 records in the data set with no filtering and no pagination)?

    How can correct it ?
  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin
    I don't know what code you are using to generate the server-side data. It will be fixable in there. I'd suggest using something like this if you can: http://datatables.net/development/server-side/php_mysql .

    Have a look at the json reply in my example server-side processing (link above) and see what is expected.

    Allan
  • pakypaky Posts: 106Questions: 0Answers: 0
    edited September 2010
    Mmm.... can I send you my php file (server-side code) ? Or paste it here ? thanks ... it's very strange :s
  • pakypaky Posts: 106Questions: 0Answers: 0
    here my code :)

    [code]
    <?php

    //MySQL connection
    $gaSql['user'] = "";
    $gaSql['password'] = "";
    $gaSql['db'] = "";
    $gaSql['server'] = "localhost";
    $gaSql['type'] = "mysql";

    $gaSql['link'] = mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password'] ) or
    die( 'Could not open connection to server' );

    mysql_select_db( $gaSql['db'], $gaSql['link'] ) or
    die( 'Could not select database '. $gaSql['db'] );

    $sess_id=$_GET['session_id'];


    /* Paging */
    $sLimit = "";
    if ( isset( $_GET['iDisplayStart'] ) )
    {
    $sLimit = "LIMIT ".mysql_real_escape_string( $_GET['iDisplayStart'] ).", ".
    mysql_real_escape_string( $_GET['iDisplayLength'] );
    }

    /* Ordering */
    if ( isset( $_GET['iSortCol_0'] ) )
    {
    $sOrder = "ORDER BY ";
    for ( $i=0 ; $iAvanzamento_Evento()).'",';
    $sOutput .= '"'.addslashes($aRow['eve_id']).'",';
    $sOutput .= '"'.addslashes(date("d/m/Y",strtotime($aRow['eve_data_start']))).'",';
    $sOutput .= '"'.addslashes(date("d/m/Y",strtotime($aRow['eve_data_end']))).'",';
    $sOutput .= '"'.addslashes($my_ev->Durata_Evento()).'",';
    $sOutput .= '"'.addslashes($descriz_accorc).'",';
    $sOutput .= '"'.addslashes($aRow['tce_desc']).'",';
    $sOutput .= '"'.addslashes('elimina').'"';



    //
    aggiungi itinerario
    /*
    if ( $aRow['version'] == "0" )
    $sOutput .= '"-",';
    else
    $sOutput .= '"'.addslashes($aRow['version']).'",';
    $sOutput .= '"'.addslashes($aRow['grade']).'"';
    */
    $sOutput .= "],";
    }
    $sOutput = substr_replace( $sOutput, "", -1 );
    $sOutput .= '] }';

    echo $sOutput;


    function fnColumnToField( $i )
    {
    if ( $i == 0 )
    return 'eve_id';
    else if ( $i == 1 )
    return 'eve_data_start';
    else if ( $i == 2 )
    return "eve_data_end";
    /*else if ( $i == 3 )
    return "version";
    else if ( $i == 4 )
    return "grade";
    */

    }
    ?>
    [/code]
  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin
    You haven't got SQL_CALC_FOUND_ROWS in your query. Have a look at the example: http://datatables.net/development/server-side/php_mysql

    Allan
  • pakypaky Posts: 106Questions: 0Answers: 0
    Thanks Allan and xcuse me for useless post :( after many copy and paste !!!! :D I accidentally deleted a piece of this code ...

    thanks
This discussion has been closed.