Individual column searching (select inputs)
Individual column searching (select inputs)
Dorababu
Posts: 17Questions: 2Answers: 0
Hello all I modified the code which was here https://www.datatables.net/examples/api/multi_filter_select.html to add the drop downs next to header which is here
https://jsfiddle.net/6kjm02eh/
But when I click on the drop down it is sorting, can it be stopped? Also I am using MVC code to bind the grid and have the required code. But with Individual column searching how to filter and show the filtered data
This question has an accepted answers - jump to answer
Answers
Create two headers; one for sorting and one for the search inputs. Use
orderCellsTop
to move the sorting to the top header row. Similar to this example. You can find lots of threads regarding this on the forum if you need more examples.Kevin
Thanks Kevin, can it be shown like drop downs instead of text boxes and fill the values
Yes. There are lots of examples on the forum like this example.
Kevin
Thanks how about filtering on the server side? How can I do that for search we are doing this way.
string search = Request.Form.GetValues("search[value]")[0];
Is there a similar way for this
I am able to do this way but I am getting some special character
Request.Form.GetValues("columns[1][search][value]").FirstOrDefault()
Can we remove special characters
^Barge/pontoon/floating dock$
OK got it I fixed here I removed the special characters
column
.search(val ? '' + val + '' : '', true, false)
.draw();
Hi one more question when I turn off this property the drop down filter is not working
"filter": false,
Also it is possible to have a date picker when there is a date column instead of select. Can it be customized like that
The example uses
.search( val ? '^'+val+'$' : '', true, false )
. Thecolumn().search()
docs explain the other parameters, ie,true, false
. The^
and$
are regular expression tokens. As you found you can remove those. Plus you can remove the two parameters if you want.That is correct. The
searching
option turns off searching. You usedfilter
which is the old (Datatables 1.9 version) of the option. If you are trying to remove the default global search input then use thedom
option to remove it but leavesearching
turned on.Yes. You can add a datetime picker. Datatables has a datetime picker extension or you can use your own. The example I provided uses a classname to determine which columns to apply the select input. You can do something similar to apply the datetime picker to the selected columns.
Kevin