0

I would like to disable the datatable checkbox (which is the first column of my table). Basically, when a button is clicked, all selected checkboxes should be disabled.

I am able to get the indices of selected rows by using

table.column(0).checkboxes.selected();

But I'm not quite sure how to proceed from there, aka how to reference the checkbox elements. I've tried using

var checkboxes = document.querySelectorAll('input[type=checkbox]')

to get all checkboxse, but I wasn't able to use prop('disabled', false). For example, when I do

checkboxes[1].prop('disabled', false)

I get the "prop is not a function" error.

Could someone help me here?

1 Answer 1

1

checkboxes isn't a jQuery object so it doesn't have a prop function. Use var checkboxes = $('input[type=checkbox]') instead and see if that works. Also, you probably want to set disabled to true, not false.

Sign up to request clarification or add additional context in comments.

2 Comments

That didn't eliminate the error. However, I found that I could directly access the property by doing checkboxes[1].disabled = true, and that worked for me.
If you figured it out - great. If not, go ahead and post a snippet of your html and JS and I'll continue to help as best I can

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.