Disable all checkboxes in table

Disable all checkboxes in table

brendonsbrendons Posts: 39Questions: 14Answers: 1

The code below disables all table controls except the checkboxes. How can I disable the checkboxes too?
My Datatable is named fritidsList and my checkboxes have the class .friChk. I have tried to target all checkboxes, all inputs etc. but I just can't find the right setting. Any help would be appreciated.

if (userRole === "teacher" || userRole === "library") {
                    editor.disable();
                    table.buttons().disable();
                    table.select.style('api');
                    $('#fritidsList :input.friChk').prop("disabled", true);

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin

    Do you mean checkboxes like in this example or actual HTML input checkboxes?

    Could you link to the page showing the issue so I can see what is happening please?

    Allan

  • brendonsbrendons Posts: 39Questions: 14Answers: 1

    Hi Allan, the checkboxes are HTML input checkboxes like your example https://datatables.net/blog/2014-09-09#Complete-code

  • brendonsbrendons Posts: 39Questions: 14Answers: 1
    Answer ✓

    Hi again. I solved it. I put the disabled property in the row callback.

    rowCallback: function (row, data) {
                            // Set the checked state of the checkbox in the table
                            $('input.friChk', row).prop('checked', data.enr_fritids_schedule.FriChk == 1);
                            if (userRole !== "admin" && userRole !== "fritidsLeader") {
                                $('input.friChk', row).prop('disabled', true);
                            }
                        }
    

    Thanks for the help. Please close the ticket.

This discussion has been closed.