Open sebbalex opened 7 years ago
To support custom filtering, e.g. ranges, the filtering operation needs to be done by the model. The plugin itself does only very basic filtering.
Right now the plugin supports delegating global filtering to the model. The functionality is missing for individual ('local') column filters. See https://github.com/ypnos-web/cakephp-datatables/blob/master/src/Controller/Component/DataTablesComponent.php#L97 It is pretty easy to add though.
In the yadcf example, it seems that like with regular column filters, columns[?][search][value]
is set in the request. So this is what is already handled in the component (see $localSearch
), but the part is missing to set it as a finder option.
Would you like to help with the implementation?
Hello, Thanks for the tips. In first place i made some test just integrating yadcf with your plugin and all filters were working fine except for the range who need some customization inside your Controller. I wrote something to get things working: 1) modified the _filter() function to identify which field has that filter (need to improve) 2) _addCondition() has now a section for handle between filters 3) find() now call the model with right where condition (using between)
After all I made some test and seems to be ok, every filters working great together even with globalSearch. I will test again all the features to be confident and I'll be back here.
Here the code and, sure, thanks. DataTablesComponent.php.zip
Front end:
$('#data-table').dataTable().yadcf([ { column_number: 2, filter_type: "range_date", date_format: "dd/mm/yyyy", filter_delay: 500, text_data_delimiter: '|', filter_default_label: ['Da','A'] },{...} ], 'footer');
Pleas just note this is an alpha release and could have bugs or unexpected behavior, feel free to improve it.
My need is a date range filter, Is there a way to have it in column? I found yadcf but I think there might be a server side code who can handle this specific filter which, for sure, is not implemented. Are there some other way to satisfy my needs or if you just have some tips to understand which is the right way to implement it?
Thanks.