Getting error "TypeError: i is undefined" when setting global search on ServerSided Datatable
Getting error "TypeError: i is undefined" when setting global search on ServerSided Datatable
Hi all,
I am kinda desperate trying to find a solution for this; I had a no-serversided datatables working, and an input working as a global search using fnFilter.
Now that I needed to change the way it works due to high volume of db entries, I have to implement another global search on the table, since fnFilter won't work anymore (I think).
The problem is, whatever approach I take to do so, I always get "TypeError: i is undefined" on the jquery.datatables.js
I tried to do it using oSearch:
"oSearch": {"sSearch": "Initial search"}
and after seeing it is a legacy feature, searched some more and found this:
var table = $( '#mytable' ).DataTable();
table.search( 'initial search value' ).draw();
Tweaked it up a bit to use the previous search box and got this:
$('#input_search_datatable').keyup(function() {
$('#example').DataTable().search($(this).val()).draw();
});
On the first method, the error appears as soon as the page loads, on the other one it triggers each time I press a key (due to the keyup event).
I can't seem to find the solution to this, can anyone help me please?
Best regards,
José
Answers
Small update:
after some changes (including adding a column search for serversided DT's - http://coderexample.com/dataTable-custom-column-search/ ), I figured that the problem pops when I try to search the column that, on the database, is a SUM of records from a JOIN (I am using a modified version of ssp that allows joins - https://emranulhadi.wordpress.com/2014/06/05/join-and-extra-condition-support-at-datatables-library-ssp-class/ ).
With the column filter I managed to test each search by column, and the only one I can't get to work is the SUM one. I checked with fiddler and the $_GET is going correctly, and I modified the ssp so that it can handle a HAVING clause so it can compare with the alias made for the SUM result