Checkboxes don't remember state (when I set through prop in js)

Checkboxes don't remember state (when I set through prop in js)

LornexLornex Posts: 1Questions: 1Answers: 0
edited April 2021 in DataTables

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.

Answers

This discussion has been closed.