How to find and set checked state of checkbox in a specific cell

How to find and set checked state of checkbox in a specific cell

robmiltonrobmilton Posts: 14Questions: 2Answers: 0

I've been searching the forums and Google for the past several hours trying every example I can find, but I'm stumped...

I am displaying JSON data in a table with one of the columns holding boolean data and being displayed as a checkbox. This works fine. I've also hooked a listener to the checkboxes to take action on click which also works fine.

When the user clicks a checkbox ultimately the property represented by that cell will be updated. But first I want to challenge the user to confirm they really want to make the change. I'm passing the table, row, and existing boolean value to my method that challenges the user. If the user responds "No" to the challenge I want to return the checkbox to it's initial state. But I can't figure out how to find the checkbox input object. I've tried:

obj.table.cell({ row: obj.row.index(), column: 8 }).prop('checked', obj.isAdmin);

$('input', obj.table.cell({ row: obj.row.index(), column: 8 }).node()).prop('checked', obj.isAdmin);

$('input', obj.table.cell({ row: obj.row.index(), column: 8 })).attr('checked', obj.isAdmin);

var $tr = $(obj.row.nodes());
var $chk = $tr.find('td:first-child input[type="checkbox"]');
$chk.prop('checked', obj.isAdmin);

However, I'm not able to return the checkbox checked status to it's original state if the user indicates "no" to the challenge.

How can I find my checkbox input object in a specific row/column and set it's checked state?

This question has an accepted answers - jump to answer

Answers

This discussion has been closed.