Skip to content Skip to sidebar Skip to footer

Datatables Filter With Statesave Cause Issue When Headers Order Changed

I have an html page and some javascript code. Below is my working html:

Solution 1:

CAUSE

Your code dtGridHelpDesk.api().column(colIdx).header() returns th cell from bottom header row which doesn't contain input elements after you switched order of header rows.

SOLUTION 1

The way your code is written, the easiest solution is to use the orderCellsTop option. It will make DataTables return th cell from top header row when you call column().header() API method.

"orderCellsTop":true

It will not cause any problems now because you have ordering disabled. If you decide to enable ordering later, this solution will cause issues because your top row has search boxes and not column headings.

SOLUTION 2

Better solution is to replace code:

$('input', dtGridHelpDesk.api().column(colIdx).header())

with:

$('input', $('th', dtGridHelpDesk.api().table().header()).eq($(dtGridHelpDesk.api().column(colIdx).header()).index()))

This code looks for search boxes in th cells of both header rows, not just bottom one.

Post a Comment for "Datatables Filter With Statesave Cause Issue When Headers Order Changed"