Please help me with filter input

Please help me with filter input

shadeonershadeoner Posts: 7Questions: 1Answers: 0

Hello,

I have used 3hours trying to make works filters (like here http://datatables.net/examples/api/multi_filter.html )

Here it is my code :

$(document).ready(function(){

var table = $('.data-table').dataTable({
    "bProcessing": true,
    "bServerSide": true,
    "sServerMethod": "POST",
    "sAjaxSource": "/ajax/establishments?franchise=0",
    "bJQueryUI": true,
    "aaSorting": [[ 0, "desc" ]],
    "iDisplayLength": "50",
    "sPaginationType": "full_numbers",
            "oLanguage": {
                "sProcessing": 'Chargement En Cours ...',
                "sLengthMenu": "Afficher _MENU_ lignes",
                "oPaginate": {
                    "sFirst" : " << ",
                    "sLast" : " >> ",
                    "sNext" : " > ",
                    "sPrevious" : " < "
                  },
                "sZeroRecords": "Aucun Résultat",
                "sInfo": "_END_ résultat(s) (_TOTAL_ au total)",
                "sSearch" : "Recherche"
            },
            "aoColumns" : [
                { "mData" : "id", "bSortable": false},
                { "mData" : "name", "bSortable": false},
                { "mData" : "street", "bSortable": false},
                { "mData" : "city", "bSortable": false},
                { "mData" : "categoryName", "bSortable": false},
                { "mData" : "date", "bSortable" : false},
                { "mData" : "author", "bSortable": false},
                { "mData" : "menu", "bSortable": false},
                { "mData" : "photo", "bSortable": false},
                { "mData" : "scoreQualityInformation", "bSortable": false},
                { "mData" : "scoreRank", "bSortable": false},
                { "mData" : "status", "bSortable": false},
                { "mData" : "actions", "bSortable": false}
            ], 
            "sDom":'<""ilf>rt<"F"p>'
});

$(".data-table thead input").on( 'keyup change', function () {
    table
        .column( $(this).parent().index()+':visible' )
        .search( this.value )
        .draw();
} );

});

The datatables is well initialized, but since I try to type something in an input it does not work, and have this message in my console :

"Uncaught TypeError: undefined is not a function", on the line number of this : .column( $(this).parent().index()+':visible' )

Thank you very much for your help !

Answers

  • shadeonershadeoner Posts: 7Questions: 1Answers: 0

    it's ok, I used filterColumn()

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    The second most popular (although it might soon claim the top spot I think) FAQ is the reason for this: http://datatables.net/faqs/#api

    Allan

  • shadeonershadeoner Posts: 7Questions: 1Answers: 0

    Hi Allan, thanks for this, maybe my english is not enought, but I rade many times forum or FAQ, I did not find anything

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    Change:

    var table = $('.data-table').dataTable({

    To

    var table = $('.data-table').DataTable({

    i.e. capital D as the FAQ states.

    Allan

  • shadeonershadeoner Posts: 7Questions: 1Answers: 0

    ohhhhh Ok ...
    Thank you Allan !

    That's maybe fnDelay did not work too :p

This discussion has been closed.