fnFilter does'nt work.

fnFilter does'nt work.

pearly_030pearly_030 Posts: 42Questions: 0Answers: 0
edited December 2011 in General
Hello,
fnFilter does'nt work.
No error in console and no change on display when I change the destination's value.
I don't understand.

"sAjaxSource": "./server_processing3.php" displays all enregistrements of my sql table.

If you can help me ?
Thanks.

My script
[code]
$(document).ready(function() {
var oTable1 = $("#reservees").dataTable({
"sDom": 'T<"clear">lrtip',
"aaSorting": [[ 4, "asc" ]],
"sPaginationType": "full_numbers",
"bFilter": true, /*search*/
"bAutoWidth": false,
"bPaginate": true, /* flèches de pagination */
"bRetrieve": true,
"iDisplayLength": 7,
"bLengthChange": false, /* Affichage de l\'information "Show xx entries" */
"bInfo": true, /* Affichage de l\'information showing xx to yy of zz */
"bVisible": true,
"oLanguage": {
"sProcessing": "Traitement en cours...",
"sLengthMenu": "Afficher _MENU_ éléments",
"sZeroRecords": "", //"Aucun élément à afficher",
"sInfo": "Réservations _START_ à _END_ sur _TOTAL_",
"sInfoEmpty": "Aucune réservation. ",
"sInfoFiltered": "", // "(filtré de _MAX_ éléments au total)"
"sInfoPostFix": "",
"sSearch": "Search all columns:",
"sUrl": "",
"oPaginate": {
"sFirst": "Premier",
"sPrevious": "Précédent",
"sNext": "Suivant",
"sLast": "Dernier"
}
},
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "./server_processing3.php",
"fnServerData": function ( sSource, aoData, fnCallback ) {
aoData.push( { "name": "min", "value": $("#min").val() } );
aoData.push( { "name": "max", "value": $("#max").val() } );
aoData.push( { "name": "sitedepart", "value": $("#sitedepart").val() } );
aoData.push( { "name": "destination", "value": $("#destination").val() } );
$.ajax( {
"dataType": "json",
"type": "GET",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
},
"aoColumns": [
/*id reservation*/ { "bSortable": false, "bSearchable": false, "sWidth": '35px', "bVisible": false },
/*id vehicule*/ { "bSortable": false, "bSearchable": false, "bVisible": false },
/*véhicule*/ { "bSortable": true, "bSearchable": true, "sWidth": '150px', },
/*qui*/ { "bSortable": true, "bSearchable": true, "sWidth": '150px' },
/*Date départ*/ { "bSortable": true, "bSearchable": false, "sWidth": '95px', "sType":'uk_date'},
/*Heure départ*/ { "bSortable": false, "bSearchable": false, "sWidth": '100px'},
/*Date retour*/ { "bSortable": false, "bSearchable": false, "sWidth": '95px' , "sType":'uk_date'},
/*Heure retour*/ { "bSortable": false, "bSearchable": false, "sWidth": '100px' },
/*Site de départ*/ { "bSortable": true, "bSearchable": false, "sWidth": '200px' },
/*id site depart*/ { "bSortable": false, "bSearchable": false, "bVisible": false },
/*ville Destination*/ { "bSortable": true, "bSearchable": true, "sWidth": '200px' },
/*id site destination*/ { "bSortable": false, "bSearchable": true, "bVisible": true },
/*Nombre de passagers*/ { "bSortable": false, "bSearchable": false, "sWidth": '20px'},
/*matricule*/ { "bSortable": false, "bSearchable": false, "bVisible": false }

/*Ville Depart{"bSortable": false, "bSearchable": false, "bVisible": false }*/
]
});
$("#destination").change( function() {

var oTable = $("#reservees").dataTable();
oTable.fnFilter($(this).val(),11);

} );
});
[/code]

html code where there is my select field "destination"
[code]
...form... table... tr .....
echo '
Site de destination
';

echo '';
echo '';
connexion_sql();
$query = "SELECT DISTINCT ville,id FROM villes ORDER BY ville";
$dbresult = mysql_query($query);
while($row = mysql_fetch_assoc($dbresult)) {
$value = $row['id'];
$texte = $row['ville'];
echo ''.$texte.'';
}
echo '';
echo '';
....../tr....../table.../form
[/code]

Replies

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    > "bServerSide": true,

    So the filtering is being done by the server. Have you implemented filtering in the server-side script? Are you using a modification of my own demo sever-side script?

    Allan
  • pearly_030pearly_030 Posts: 42Questions: 0Answers: 0
    Yes i'm using your demo server-side script.
    the fnFilter works with server-side or not.

    I program filter (test on each field value) in the server-side script and then it's OK.

    a fnFilter method exists for server-side script ?
  • pearly_030pearly_030 Posts: 42Questions: 0Answers: 0
    Allan,

    A new question in the same domain.
    In aoColumns i program [code]bSortable": true[/code] for one column.
    It does'nt work.
    is it the same problem ?
    I've to sort data in the server-side script ?
    if yes, how ?

    Thanks.
  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    What does your server-side script look like? fnFilter and sorting should both work just fine in my demo script: http://datatables.net/development/server-side/php_mysql

    Allan
  • pearly_030pearly_030 Posts: 42Questions: 0Answers: 0
    Yes i use your demo script and I think that the columns's order must be the same in the datatable and in the database's table.
    In my case, it's not the same then i sort array's datas like it :
    [code]
    .......
    $output["vvData"][] = $row;
    }

    // tri des données
    if ( isset( $_GET['iSortCol_0'] ) ){
    foreach ($output["vvData"] as $key => $row) {
    $tri[$key] = $row[$_GET['iSortCol_0']];
    }
    if ($_GET['sSortDir_0'] == "asc") {
    array_multisort($tri, SORT_ASC, $output["vvData"]);
    }
    if ($_GET['sSortDir_0'] == "desc") {
    array_multisort($tri, SORT_DESC, $output["vvData"]);
    }
    }
    [/code]

    and paging :
    [code]
    // Affichage des données en fonction de la pagination
    $output1 = array("sEcho" => $total_v , "iTotalRecords" => $iTotal , "iTotalDisplayRecords" => $iFilteredTotal , "aaData" => array());

    $start = $_GET['iDisplayStart'];
    $longueur = $_GET['iDisplayLength'] - 1;
    $end = $start + $longueur;

    for ($i = 0; $i < $iFilteredTotal; $i++) {

    if (isset($output["vvData"][$i])) {

    if ($i >= $start AND $i <= $end) {
    $row = $output["vvData"][$i];
    $output1["aaData"][] = $row;
    }
    }
    }

    echo json_encode($output1);
    [/code]

    For fnFilter , actually i don't find the solution, I will try again later.

    Many thanks.
This discussion has been closed.