This is a migrated thread and some comments may be shown as answers.

radGRID CHECKBOX VIA JAVASCRIPT

6 Answers 187 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dave Navarro
Top achievements
Rank 2
Dave Navarro asked on 05 Nov 2008, 05:23 PM
Hello,

I'm trying to find information about a property that exists in the radGrid cells; the checkbox - "childNodes[1].checked".

I have a dataset that is being loaded at runtime and my columns are set to automatic so when the radGrid finds a boolean DataType it automatically creates a checkbox in the cell. Ok, no problem so far.

At runtime, the user selects a row and I must determine if the checkbox is "checked" or "unchecked" via Javascript.

My trouble began when I searched the help files and didn't find anything describing the "childNodes[1].checked" property.

Here's a code snippet of what I'm trying but isn't working;

var gridIsCommodityValue = MasterTable.getCellByColumnUniqueName(row, "isCommodity").childNodes[0].checked;)

if (gridIsCommodityValue.checked) {
    alert("This checkbox is checked!");
else {
    alert("This checkbox is NOT checked!");
}

It seems like this should work but regardless of the checkbox being checked or unchecked my returned value is null.

Any suggestions?

Also, does anyone know where in the help files I can find the reference to the checkbox properties? I just can't seem to find it.

Many thanks in advance,

Dave

6 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 05 Nov 2008, 06:07 PM
Hello David,

For your convenience I created an example illustrating two possible approaches. Please test it locally and let me know if you have more questions.

I hope my directions are helpful

Best regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Dave Navarro
Top achievements
Rank 2
answered on 05 Nov 2008, 06:34 PM
Thanks for the quick response!

I'm able to use the method; radgrid.get_masterTableView().get_dataItems()[row].get_cell("Discontinued").children[0].children[0].checked;

This returns a "true" or "false" and fits right into what I'm already doing. The big difference with my code was that I was instructed to use ".childNodes[1].checked" but that was failing and I wasn't able to find information about this topic in the help files.

Adding an additional proptery ".childNodes[0]" made the difference.

So, where is this information found in our help files???

Please let me know and thanks for your help!!!

Dave 
0
Daniel
Telerik team
answered on 07 Nov 2008, 03:38 PM
Hello David,

Please notice that children[0] / childNodes[0] in this case is SPAN element. The desired control (input type="checkbox") is nested inside the mentioned element.

Actually I suggest you to use childNodes instead of children in order to avoid problems under Mozilla Firefox.

Best regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Dave Navarro
Top achievements
Rank 2
answered on 07 Nov 2008, 06:24 PM
Ok, I'll take another look at the statements and adjust them per your recommendation.

I still would like to see this information in the help files. Can you submit a request to have the help files updated with this information so we don't have to come here to the forums to get this info?

Thanks for your help!

Dave
0
Daniel
Telerik team
answered on 10 Nov 2008, 03:19 PM
Hello David,

I'd like to thank you for your recommendation.

Regarding the DOM tree: We consider this as a general JavaScript knowledge and therefore we don't have such an article currently. For your convenience I present you several screenshots illustrating how to find the desired element using the debugger. Please examine them and let me know if you need any clarification regarding this approach.

Best regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Dave Navarro
Top achievements
Rank 2
answered on 10 Nov 2008, 05:41 PM
Thank you for that detailed response. The screen shots were a great help.

I think I understand why you say it's considered general knowledge... since I can look it up myself. I guess I figured that since the help files contain so much information about client side objects, properties and methods I would have found a clue about its existence in the help file without having to use the debug method and search for it as you've described.

I'll be sure to use this method from now on and thanks to your post, others (who don't know about this method) can learn from it as well.

Thank you so much for the help AND lesson!

Case closed!

Take care,

Dave
Tags
Grid
Asked by
Dave Navarro
Top achievements
Rank 2
Answers by
Daniel
Telerik team
Dave Navarro
Top achievements
Rank 2
Share this question
or