Targeting a column filter if a column before is not visible
Targeting a column filter if a column before is not visible
I recently asked this question:
This appeared to work - BUT if I have column visibility enabled and one of the columns before the above scenario of filtering the column are hidden then the target to reset the filter won't work because it is taking into account the invisible column in the numbering which I am referencing.
Is there a way to get this to work? I have tried targeting like this:
$('#example thead tr:eq(1) th:visible:eq('+column+') input').val('')
But this doesn't work - I need either a way of targeting visible inputs or to target the filter input css ID but I can't seem to be able to match the filter name e.g. #filter-customer on the input to the column number being passed back from column-visibility.dt
As my columns are in DataTables the ideal would be to get the column name back rather than the ID, anyway to do that?
I tried:
table.columns(column).name()
and
table.column(column).name()
with no luck.
This question has an accepted answers - jump to answer
Answers
PS I also thought I could use the th's data-column-index="3" but this number moves when colReorder is used so doesn't match the column index response.
Hi @greenman123 ,
Good spot, I never considered that. This here will resolve that - it gets the index for the node.
Cheers,
Colin