radGRID CHECKBOX VIA JAVASCRIPT

7 posts, 1 answers
  1. Dave Navarro
    Dave Navarro avatar
    150 posts
    Member since:
    Jul 2005

    Posted 05 Nov 2008 Link to this post

    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
  2. Answer
    Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 05 Nov 2008 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Dave Navarro
    Dave Navarro avatar
    150 posts
    Member since:
    Jul 2005

    Posted 05 Nov 2008 Link to this post

    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 
  5. Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 07 Nov 2008 Link to this post

    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.
  6. Dave Navarro
    Dave Navarro avatar
    150 posts
    Member since:
    Jul 2005

    Posted 07 Nov 2008 Link to this post

    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
  7. Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 10 Nov 2008 Link to this post

    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.
  8. Dave Navarro
    Dave Navarro avatar
    150 posts
    Member since:
    Jul 2005

    Posted 10 Nov 2008 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017