Reset checkbox filter using datatable API
Reset checkbox filter using datatable API

Hello folks,
I am trying to reset the checkbox filter and successfully able to uncheck or reset it, but the datatable is not picking up the changes. When I try to choose any other option from the checkbox after the reset process, it shows me the previous chosen option.
$jQuery(".wdt-checkbox-filter[data-col-index='4']:checked")
.prop("checked", false)
.trigger("change");
wpDataTables.table_1.api().draw();
What I am doing wrong, any help would be really appreciated.
Answers
What checkbox filter? Can you link to a test case showing the issue, per the forum rules please? Is it something that is added by wpDataTables perhaps?
Allan
Hi Allan,
I have filters in my datatable. The type of the filter is checkbox. When I try to reset it like this:
var table = new DataTable('#myTable');
table.columns(3).search('').draw();
It is not resetting it. The checkbox is getting cleared using this jquery code but the datatable is not taking the effect.
here is how I am resetting the checkbox using jquery.
$jQuery('#table_1_'+columnIndex +'_filter input[type="checkbox"]').prop('checked', false);
My objective is to reset or clear that particular filter (which is my checkbox filter) in the datatable filters.
DataTables core doesn't provide checkbox filters, so I'm not sure what checkboxes you are referring to, and the API wouldn't be resetting them since it knows nothing about them.
As requested, please link to a test case so I can understand a bit more about the checkboxes.
If it is something that is added by wpDataTables, you'd need to contact them to ask if they can add a reset API.
Allan