Open fr0z3nfyr opened 9 years ago
Hey @fr0z3nfyr, sorry I've been busy. I'll take a look either in the next an hour or so, if not, then tomorrow.
Can you paste your component config and the js settings you're initializing jquery datatables with?
For range filter, you'll need to use a custom search method on that column. It looks like sSearch0 would be in a format like "fromvalue-tovalue" so the custom find would need to explode on that separator to get the two values.
Custom find works like this:
public $components = [
'DataTable.DataTable' => [
'User' => [
'columns' => [
'id' => ['bSearchable' => 'rangeFilter'],
'username',
'email'
],
],
];
In your model add a function like:
public function rangeFilter($column, $searchTerm, $columnSearchTerm, $config) {
// you can then check $columnSearchTerm and add conditions on `$config->conditions`
}
But yadcf states that it supports only server-side processing (1.10.0 +)
which my plugin doesn't handle. I don't know how you have any of this working.
Hey sorry, I was sick with a fever, just checked your comment. I will post my component settings as soon as I get back on the project. Meanwhile you can check my interaction with author of yadcf @ http://stackoverflow.com/questions/31045543/ I too was a little confused originally but somehow (probably by fluke) got it working this far. I will also post an implementation for Daniel(yadcf author) on his thread(see comments on answer on SO link).
I would like to implement range filters similar to what is used here http://www.alpha.mobotrix.com/cake/users but not necessarily using YADCF.
@destinydriven the backend is setup for this but you need to manually add the column filters and call the filter function with jquery plugin. See https://legacy.datatables.net/examples/api/multi_filter.html
The important bit is calling
$("tfoot input").keyup( function () {
/* Filter on the column (the index) of this element */
oTable.fnFilter( this.value, $("tfoot input").index(this) );
} );
where otable is a reference to the datatables object for your specific table.
@tigrang So I need to override render() in the Helper so I can inject the footer into the table?
@destinydriven check this gist out for an exmaple. https://gist.github.com/tigrang/e6b9d53a407280f791f3abceea285394
@tigrang Awesome thanks, that worked great for me. Perhaps we can add this to the wiki. I'm sure it's a much requested feature.
@destinydriven is containable actually making a join or is it doing a separate query? Can you check sql log?
@tigrang It's doing a left join.
@destinydriven can you hop on irc?
How can I get range filters to work? I have two inputs for a column to do a range search, see image for sample. when I check in console, i get
sSearch_0
,sSearch_1
,sSearch_2
,sSearch_3
in config.One, why is![sample](https://cloud.githubusercontent.com/assets/5248866/8402707/5913921e-1e5b-11e5-9009-20548b4a4154.png)
sSearch3
required if there is no search on the last column. I think I have to check DT also to see if that is a mandate. Two, I'm using YADCF for column filtering, so for the range filter, the searched range returns 0 rows. Probably, the query to DB is being passed incorrectly. How can I fix this? I'm supposing that the range filters for dates will also misbehave, I haven't tested.