1

I'm using IgnitedDatatables (CodeIgniter library) for DataTables. The table gets generated without problems but if I search/filter it can only filter one column at a time. If I set "bServerSide" to false it works but then I lose the server-side functionality.

In the examples, this one is working: http://datatables.net/release-datatables/examples/ajax/custom_data_property.html

while this isn't (server-side): http://datatables.net/release-datatables/examples/data_sources/server_side.html

Is this not possible to achieve when running server-side?

This is my JSON response (shortened and with replaced data):

{"sEcho":0,"iTotalRecords":45438,"iTotalDisplayRecords":45438,"aaData":[["abc","12345","[email protected]","","","2010-01-27 22:31:10","Edit<\/a> Delete<\/a>"],["abc2"," test123","[email protected]","","","2008-06-15 22:09:33","Edit<\/a> Delete<\/a>"]],"sColumns":"fname,lname,email,phone,cellphone,created,edit"}

JavaScript code:

$("#members").dataTable( {
    "bProcessing": true,
    "bServerSide": true,
    'sAjaxSource': '<?php echo base_url();?>members/listener',
    "fnServerData": function ( sSource, aoData, fnCallback ) {
        $.ajax( {
            "dataType": 'json',
            "type": 'POST',
            "url": sSource,
            "data": aoData,
            "success": fnCallback
        } );
    },
    "bLengthChange": false,
    "aaSorting": [[ 0, "asc" ]],
    "iDisplayLength": 15,
    "sPaginationType": "full_numbers",
    "bAutoWidth": false,
    "aoColumnDefs": [ 
        { "sName": "fname", "aTargets": [ 0 ] },
        { "sName": "lname", "aTargets": [ 1 ] },
        { "sName": "email", "aTargets": [ 2 ] },
        { "sName": "phone", "sWidth": "80px", "aTargets": [ 3 ] },
        { "sName": "cellphone", "sWidth": "100px", "aTargets": [ 4 ] },
        { "sName": "created", "sWidth": "120px", "aTargets": [ 5 ] },
        { "bSortable": false, "sName": "edit", "sWidth": "115px",   "aTargets": [ 6 ] }
    ]
});

Thank you!

1 Answer 1

1

Well, the problem if you filter server side is that you are filtering through an SQL query and this is what is written on the example you posted;

  • Filtering
  • NOTE this does not match the built-in DataTables filtering which does it
  • word by word on any field. It's possible to do here, but concerned about efficiency
  • on very large tables, and MySQL's regex functionality is very limited

Basically you could do what you want to do (a regular expression match an all columns) but it's going to kill the performance server side.

What i usually do is provide a filter for each column, i need to filter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.