Column Filtering with Reordering - searches wrong column after reorder?
Column Filtering with Reordering - searches wrong column after reorder?
tomnf
Posts: 1Questions: 0Answers: 0
Hi,
I'm new to DataTables so forgive me if I'm missing something!
I am using Individual Column Filtering as well as Column Reordering. Both work great by themselves, but if I move a column to a later position and attempt to use it's filter, it filters data from the column that's now at it's original index instead of the column I am trying to filter on.
I did some debugging and can see it's passing the column's "new" index to the oTable.fnFilter function, which seems correct, so I can't understand why/how it would be filtering a different column.
I couldn't find any examples of the two being used together with filtering turned on - does anyone know if this should work or how to resolve?
Thanks,
Tom
I'm new to DataTables so forgive me if I'm missing something!
I am using Individual Column Filtering as well as Column Reordering. Both work great by themselves, but if I move a column to a later position and attempt to use it's filter, it filters data from the column that's now at it's original index instead of the column I am trying to filter on.
I did some debugging and can see it's passing the column's "new" index to the oTable.fnFilter function, which seems correct, so I can't understand why/how it would be filtering a different column.
I couldn't find any examples of the two being used together with filtering turned on - does anyone know if this should work or how to resolve?
Thanks,
Tom
This discussion has been closed.
Replies
you can scan through oTable.fnSettings().aoColumns[] to match column names to column numbers rather than hard-coding an index number, if this makes your code more readable and manageable.
[code]
var index = $(this).parent("tr").children().index($(this));
if (index)
{
this.innerHTML = fnCreateSelect(oTable.fnGetColumnData(index));
$('select', this).change(function()
{
oTable.fnFilter($(this).val(), index);
});
}
[/code]
This works great, but the trick is to get it to run when a column is dragged and dropped. I'm not sure what callback I can tap for this. The draw callback didn't fire after dropping a column into a new place. If I was able to tap into a callback, I could use the above code without the line that assigns the innerHTML to reset the indexes, I believe.