Datatable dropdown box list instead of search text box
Datatable dropdown box list instead of search text box
is it possible to change search text box. i want to select box instead of text box
This discussion has been closed.
is it possible to change search text box. i want to select box instead of text box
Replies
Hi @harit ,
There's isn't one out of the box, so you'll need to create one. The
domcan be used to remove the current search box, then you can create your own dropdown to initiate a search instead. This example here creates dropdown searches in the footer, but you could use that code as a template,Cheers,
Colin
thanks for the replay colin
Hi,
I've used the code in the example above to create a dropdown for a date column. The column itself has a
Y-m-dformat but in the drop down I only want to haveY-mto filter for months.If I just use the code as is, in the dropdown each individual date will appear.
Therefore I changed the code from
to
This will cut the day from the date and I get the desired format but I will get for instance 10 times the value
2019-10in the dropdown as initially there are 10 different days in the database.To limit this to 1 appearance per month I changed the code as follows:
Is this the best way to do this or is there a better solution?
Thank you.
Caspian
@Caspian deConwy You certainly do need to keep track of the dates you've placed in the select list when doing something like this. Your code looks good.
Kevin
Thanks