Checkboxes don't remember state (when I set through prop in js)
Checkboxes don't remember state (when I set through prop in js)
Lornex
Posts: 1Questions: 1Answers: 0
Table script:
$("#table").DataTable({
stateSave: true,
columns: [
{
name: "ID",
data: "ID",
className: "ID",
orderable: false,
render: $.fn.dataTable.render.text()
},
{
name: "Name",
data: "Name",
// orderable: false,
render: $.fn.dataTable.render.text()
},
{
data: "All",
className: "selectAll"
},
{
data: "Visible"
},
{
data: "Remove"
},
{
data: "Edit"
}
],
columnDefs: [
{
targets: [2, 3, 4, 5],
orderable: false,
checkboxes: {
selectRow: true,
stateSave: true
}
}
],
select: { 'style': 'multi' },
ajax: { url: "/LoadTableData", type: 'POST', datatype: "json" },
}
})
The state is remembered only on checkboxes that were clicked in view, not on checkboxes that were set through the .js file.
ex: checkbox.prop('checked', checked);
-> this won't be remember
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This discussion has been closed.
Answers
checkboxes
isn't an option of ours - see the list here . It looks like checkboxes from @gyrocode .You probably need to use the Select extension API -
row().select()
. If not it would be worth asking on Gyrocode's site.Colin