How to display a warning if a filter (search) is applied by Yadcf?
How to display a warning if a filter (search) is applied by Yadcf?
lenamtl
Posts: 265Questions: 65Answers: 1
Hi,
All my Yadcf filters are in a collapsable box.
When the box is collapsed we don't see if there are filters set.
So I'm looking for a way to display a warning on the page if any filters is applied by Yadcf.
The only way I see is to get info from localstorage but this is complicated to parse...
Any other way to do it?
Thanks
This discussion has been closed.
Answers
This is checking for Yadfc filter and Datatable on search.
I will also add the code for on page load...
Note, this is not checking from localstorage, only from field values.
This can cause an issue in multi-language environment so it is better to check from localstorage when it is enable.
I will post the link when I will get it working.
most of yadcf filters when used got the
inuse
class... so you might wanna use it to apply a special styling to a filter that got the inuse classHi Daniel
I'm looking for a way to parse the info from the savestate localstorage value
How can I parse this from Yadcf ?
"yadcfState":{"-allmytasks-list":[null,null,null,null,null,{"from":"01/03/2018","to":"24/03/2018"}
The problem that may occurred if you only get the info from the field is the following
Let say I select a filter value from a dropdown then I get a result
Later I come back to the page the value I uses for the search is no more more available from the dropdown (for any good reason not a bug) at this point the search value is still saved in localstorage, and the field is now empty, this can cause a confusion to the user and he may think there is no filter applied as in fact there is.
Same problem in multi-language if a user switch from a language to another ....
So this is why relying on field value only is not a good idea.
When using state saving in datatables your value should be there when you leave/refresh page
yes but now I have to parse theses values from localstorage datatabase
Similare to this
https://datatables.net/forums/discussion/48280/how-to-parse-statesave-values
but from Yadcf part
"yadcfState":{"-allmytasks-list":[null,null,null,null,null,{"from":"01/03/2018","to":"24/03/2018"}