I have a WHDG with 3 levels. I have an unbound checkbox column for each row in the grid. If I click the checkbox and the band has children, I would like to set all of the child row checkboxes to be checked. Also if I uncheck a parent band, all of the child rows should be unchecked as well.
I am getting an error on the WHDG's CellValueChanged Event.
function CellValueChanged(sender, eventArgs) {var isChecked = false;isChecked = eventArgs.get_item().get_row().get_cell(0).get_element().children[0].checked;}
ERROR: eventArgs.get_item is not a function.
Hi jdymond,
That is because get_item() is not a member of those event args. If memory serves me correctly, I believe it has get_cell() or getCell(). If you want to find everything, I suggest putting a debugger; statement in the handler and examining the methods available.
regards,David Young
I have moved this the the ClickHandler Event and and now I am getting 'undefined'.
var
isChecked = false;
isChecked = eventArgs.get_item().get_row().get_cell(0).get_element().children[0].checked;
Hi again,
Once more, you're using the wrong code. You need to check that the actual item is a row before getting it as such. It is possible it could be the cell in the click event. Another thing is that the checkbox is not an <input type="checkbox" /> It is done with an image (so we can have a partial state). Once you have the cell, you could do get_value() to get whether it is checked or not (for a Boolean field and so long as it isn't partial). Off of these event args, there is a get_type() or something. Check that out. And once again, I suggest dropping in a debugger; statement and checking what is available in the event args.
-Dave
I see what you are saying. However, I mimicked this code from a sample project and it works fine there. Simple WHDG Click Event.
function ClickHandler(sender, args) {
isChecked = args.get_item().get_row().get_cell(0).get_element().children[0].checked;
var rowIndex = args.get_item().get_row().get_index();
var childGrids = whdg.get_rows().get_row(rowIndex).get_rowIslands();
for (var j = 0; j < childGrids[0].get_rows().get_length(); j++) {
childGrids[0].get_rows().get_row(j).get_cell(0).get_element().children[0].checked = isChecked;
} }
Resolved. I switched from using an unbound checkbox to a TemplateDataField and it seemed to have resolved the issue.