Custom Filter with Re-ordered Columns
Custom Filter with Re-ordered Columns

When using custom filtering, is there a way to use named columns? I used column keys, but the custom filters don't work correctly if someone re-orders the columns. Or is there a way to make the custom filters always use a specific column even when columns are re-ordered?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Note, I have it set up with ajax, and set columns like columns: [ { "name": "id", "data": "id"} ], but I only see an array with keys when using $.fn.dataTable.ext.search.push
Looks like you can use
colReorder.order()
to get the current column order. This can be used as the index tosearchData
for the search plugin. For example:http://live.datatables.net/juxukoda/1/edit
No matter what order the columns are in the plugin will print the name column.
Kevin
Trying your example, if I move the name column to the right, it starts printing different values instead of names. Like if I move Name col over to where Office is, such that it's Position, Office, Name, it starts printing Office values instead of Name values.
I see. Looks like
searchData[colOrder.indexOf(0)]
is needed instead ofsearchData[colOrder[0]]
.http://live.datatables.net/juxukoda/2/edit
Kevin
That works! Thank you very much for your help!