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 7 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

  • colincolin Posts: 12,098Questions: 0Answers: 2,054

    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

Sign In or Register to comment.