how to cacel all checkbox on DataTable
please let me know how to use code to cancel, clear all of checkbox on DataTable. not show in KTUI guide.
Thank you
Replies (1)
Hi Xin Yu
After the table is initialised, get the instance and call uncheck():
const tableEl = document.querySelector("#your_datatable");
const datatable = KTDataTable.getInstance(tableEl);
if (datatable) {
datatable.uncheck();
} Related methods:
check() — selects all visible row checkboxes
getChecked() — array of checked row IDs
update() — refreshes checkbox UI after tbody changes (pagination, reload)
With default checkbox.preserveSelection: true, uncheck() clears the current page and drops those IDs from the stored selection; other pages may still have IDs in getChecked(). To clear everything in one go, use preserveSelection: false when creating the instance, then uncheck():
const datatable = new KTDataTable(tableEl, {
checkbox: { preserveSelection: false },
// ...your other options
});
// later, to clear all:
datatable.uncheck();