Default Filter With Target Column IDs
Default Filter With Target Column IDs
peterbelove
Posts: 27Questions: 8Answers: 0
I've found this page for set the default filter in initialising.
https://datatables.net/reference/option/searchCols
I have a table of 60 columns and I need to filter on the last few columns. feel a bit dumb to do 60 'null's to get to the last few columns.
is there a way to get the target columns like this? but below doesn't work
{ "targets": [52,53], "search": "Blue" },
thanks,
This question has accepted answers - jump to:
This discussion has been closed.
Answers
You can use
columnDefs.targets
withcolummDefs
Something like this:
You can also use negative numbers if you know the columns will always be the last x number of columns.
Kevin
your code doesn't seem to work. I've created below example with your code.
http://live.datatables.net/sedurilu/1/edit
appreciate if you can take a look.
Sorry I wasn't paying close attention - only looked at your code snippet without the context of using
searchCols
. The docs state that an array needs to be the same size as the number of columns. So there is not a context of usingtargets
.You could use
column().search()
orcolumns().search()
ininitComplete
like this:http://live.datatables.net/dohirava/1/edit
Kevin
thank you! is there are way to search 2 columns together with your code?
Yep, as Kevin said, you can also call
columns().search()
which will search multiple columns.Colin
thanks a lot!
just to add here, can chain it.
table.column(1).search('director').column(2).search('london').draw();