jeudi 23 juin 2016

datatables individual column search not working


I have implemented datatable with ssp.class

when I use code from this page https://datatables.net/examples/api/multi_filter.html it looks that datatables is searching but with no result. In console I dont see any error and response with get looks it is geting some data (but there is like 20-30 get request per character in search field, many with 0 results, only few with records)

this is my code

var table2 = $('#dataTables-subjekt-childrow').DataTable( {
        'dom': 'C<"clear">lfrtip',
        'dom': 'T<"clear">lfrtip',
        'tableTools': {
                "aButtons": [
                    "copy",
                    "print",
                    {
                        "sExtends":    "collection",
                        "sButtonText": "Save",
                        "aButtons":    [ "csv", "xls", "pdf" ]
                    }
                ]
            },
        'destroy':true,
        'stateSave': true,
        'columns.orderSequence': [[0, 'asc']], 
        'processing': true,
        'serverSide': true,
        'ajax': '../list_subjekt2.php',
        'jQueryUI': true,
        'autoWidth': false,
        'searching':true,
        'lengthChange': true,
        'paging': true,
        'ordering': true,
        'pageLength': 100,
        'info': true,
        'pagingType': 'full_numbers',
        'language': {"url": "../json/datatables_slovak.json"},
        'columns': [
            { "data": "nazov", "searchable": true },
            { "data": "okres", "searchable": true },
            { "data": "kraj", "searchable": true },
            { "data": "typ", "searchable": true },
            { "data": "spravuje", "searchable": true },
             {
                "className":      'details-control',
                "orderable":      false,
                "data":           null,
                "searchable": false,
                "defaultContent": ''
            },
            {
                "className":      'details-contact',
                "orderable":      false,
                "data":           null,
                "searchable": false,
                "defaultContent": ''
            },
            {
                "className":      'details-comm',
                "orderable":      false,
                "data":           null,
                "searchable": false,
                "defaultContent": ''
            },
            {
                "className":      'details-files',
                "orderable":      false,
                "data":           null,
                "searchable": false,
                "defaultContent": ''
            },
            {
                "className":      'details-edit',
                "orderable":      false,
                "data":           null,
                "searchable": false,
                "defaultContent": ''
            },
            {
                "className":      'details-delete',
                "orderable":      false,
                "searchable": false,
                "data":           null,
                "defaultContent": ''
            }
        ],
        'order': [[0, 'asc']],
        initComplete: function ()
            {
              var r = $('#dataTables-subjekt-childrow tfoot tr');
              r.find('th').each(function(){
                $(this).css('padding', 8);
              });
              $('#dataTables-subjekt-childrow thead').append(r);
              $('#search_0').css('text-align', 'center');
            }



    } );


     $('#dataTables-subjekt-childrow tfoot th').each( function () {
        var title = $(this).text();
        $(this).html( '<input type="text" placeholder="Hľadaj '+title+'" />' );
    } );

     table2.columns().every( function () {

    var that = this;
        $( 'input', this.footer() ).on( 'keyup change', function () {
            if ( that.search() !== this.value ) {
               that
                    .search( this.value )
                    .draw();
            }
        } );
    } );

when I put in the last function instead of value "that" my table name, it puts my search in fulltext search above

how can I get this individual column search working pls?

edit: when I added that .column(this.colIdx) to my code I can see that even I put search string in my 3rd or 4th column, it is searching only in first column

 that
                    .column( this.colIdx )
                    .search( this.value )
                    .draw();

edit2: I tried to disable serverside, to handle it by client but except it is too slow, result is the same when I see parameters sent by serverside search, it sent params ok but 11requests as I have 11 columns in datatable, and for some of draws it returns correct json and for some empty. But it shows that no data to draw


Aucun commentaire:

Enregistrer un commentaire