Can I make it so a dropdown filter doesn't need the specific option?
Can I make it so a dropdown filter doesn't need the specific option?

Hi there,
In one of my datatables, there's a column with 'status' which displays the status of a submission and the date of submission. For example: unread - 2022-05-26. I'd like to be able to sort this column by only the status, without taking the date into account. Of course, I could place the date in a separate column, but I think this would look a lot cleaner. Is it possible to change the filter as such?
This discussion has been closed.
Answers
Guessing you are referring to the code in this column search example. This code builds the select list:
You can use
column().index()
to if the column is thestatus
column and if so use different code to get a unique list of statuses to populate the select options. Something like this pseudo code:Kevin
Hi Kevin,
Thanks for this example! I've got the right values in the dropdown now, but when using this dropdown to filter, it always returns no records. I guess this is the case because I'm trying to filter on 'unread', but the value in the table is 'unread - 2022-05-24' for example. Is it possible to only filter on the first part of the value in the table?
By doing the same thing with the
column().search()
. In the example it uses this regex search:Maybe something like this would work for that particular column:
The expectation is this will search for
unread
at the beginning of the string and match any characters after.Kevin
That's it! Thanks so much for your help