How to use ColumnFilter - Number Range - in DataTable Server-side processing
How to use ColumnFilter - Number Range - in DataTable Server-side processing
Hello,
first: Sorry for my english, I'm from Germany!
A few weeks ago i found DataTables and i think it's a great project! I want to run DataTables on server side and i took one of the server side scripts from the development section on your page (mysqli from Kari Söderholm, aka Haprog. It works great!
But now i want to filter my columns. I used the ColumnFilter() Plugin and it doesn't work. I have read in many forums that there are problems with the number range and date range functionality. I have the same problem. I want to filter my columns by range and need help. Is there a solution you could show me? Will there be a compatible version of any filter plugins for server side processing?
My components: DataTable 1.9.4 with server side script for mysqli
I used ColumnFilter Plugin and YADCF Plugin. Both don't work with Number Ranges!
Please help. It's important ;-)
Answers
yadcf support server side filtering since DataTables 1.10, all yadcf 8 filter types (including range date/number/number slider filters too) take a look at the showcase http://yadcf-showcase.appspot.com/server_side_source.html
Maybe I used an older version!? I will try it now and tell you. Thanks!
I tried your plugin, but had the same problems again.
I have 4 columns: Text - Number - Number - Number
For Column 0 i want use the filter_type "text" and for the other columns the filter_type "range_number" or "range_number_slider.
Displaying the formular elements is no problem. When i make an input in number range textbox, DataTable says: "No matching records found"
When I make an input in the normal textbox for Column 0 nothing happens.
The number_range_slider does not work. When i try to use it, DataTable shows the banner "processing" and the slider doesn't appear...
This is my JavaScript Code:
$(document).ready( function() { $('#example').dataTable( { "bProcessing": true, "bServerSide": true, "sAjaxSource": "GenerateTableOnServer_2.php", "fnServerData": function ( sSource, aoData, fnCallback ) { aoData.push( { "name": "table", "value": '<?php echo $table ?>' } ); $.getJSON( sSource, aoData, function (json) { fnCallback(json) } ); } } ).yadcf([ {column_number : 0, filter_type: "text"}, {column_number : 1, filter_type: "range_number"}, {column_number : 2, filter_type: "range_number"}, {column_number : 3, filter_type: "range_number_slider"}]); } );Could you pls help me?
For using the range_number_slider you should inlcude jquery slider plugin in your page as well... regarding filtering, since you are using the bServerSide you should implement the filtering on your server side, yadcf will send the relevant data regarding the filtering (min / max values or text input) to your server and you do the filtering on your own... take a look at the showcase for how to get the filtered values on server (
http://yadcf-showcase.appspot.com/server_side_source.html take a look at the second "Usage(on this page example):")
I'm a newbie in programming languages.. and your example is based on Java... i use the serverside script for mysqli, written in PHP... do you know how to modify the PHP Script to use your range_number?
This one:
http://www.datatables.net/development/server-side/php_mysqli
P.S.: I updated to 1.10 and the text filter work!
Good, as I said before "yadcf support server side filtering since DataTables 1.10" regarding the range_number, if you managed to get the relevant search value from the text filter on your server side you should be able to the same for range_number, it should look like min-value-yadcf_delim-max_value , take a look at the following issue: https://github.com/vedmack/yadcf/issues/60
I dont modify something for the textfilter. I only updated to v1.10.
I think the search values must be send to the PHP script per AJAX Post or Get, right? Do you have an example for this? I dont know how to edit the javascript code for the request to the server.
The editing of the SQL query in the PHP script shouldnt be a problem later. I only need to know how to get the values to the php script...
You don't have to modify a single line of the js code, yadcf handles all for you, you said that you managed to use the column_number : 0, filter_type: "text", right? how did you get the filtered value on your php code?
I dont get the filtered value on the php script. the only thing i did is to implement the php script in my ajax source.
there was nothing modified in the script!
Did you managed to use the global filtering with server side source (global filtering is the text input in the upper right corner of the table) I guess if you will manage to get it working *nothing to do with yadcf) You will be able to use the yadcf too, sorry that I can't help you with any PHP code...