searchCols (initial filter) not applying custom filter ($.fn.dataTable.ext.search)
searchCols (initial filter) not applying custom filter ($.fn.dataTable.ext.search)

For some reason the searchCols
option is not applying the custom filter pushed to the $.fn.dataTable.ext.search
array:
searchCols: [ { search: '1' } ],
Is there any way to trigger my custom filter before or after the table is drawn? Like using draw() inside initComplete
function?
Or a way to have the dt
object inside initComplete
?
Thanks.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
The search plugin will run each time the table is drawn. For example each time
draw()
is calls, anytime the table is searched, paged or sorted. UsingsearchCols: [ { search: '1' } ],
isn't necessarily telling the search plugin to search for the value1
in the column.Initialize it before initialize Datatables.
Typically use
draw()
.Not to fix this problem but you can use
var api = this.api();
insideinitComplete
.In order for us to help with your search plugin please post a link to your page or a test case showing us what you have done. Also let us kwon what you are expecting the search plugin to do.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Yeah, I completely forgot about
this.api()
. Now I can calldraw()
. Thanks.