accessing checkbox in node on client side

4 posts, 0 answers
  1. John
    John avatar
    6 posts
    Member since:
    Jun 2008

    Posted 12 Mar 2009 Link to this post

    Due to having to disable a checkbox but still have it visible on the client side (using client side javascript to check and uncheck it as items in a grid underneath of it are checked) I have added an asp:CheckBox to a node on the server side with the following code:

     

     

    RadTreeNode substanceNode = new RadTreeNode(substanceRow["Substance_Name"].ToString(), substanceRow["SUBSTANCE_ID"].ToString());

     

    substanceNode.ExpandedImageUrl =

    "~/Images/FolderOpen.gif";

     

    substanceNode.ImageUrl =

    "~/Images/FolderClosed.gif";

     

     

    CheckBox indicator = new CheckBox();

     

    indicator.Enabled =

    false;

     

    indicator.Visible =

    true;

     

    indicator.ID =

    "chkSource";

     

    substanceNode.Controls.Add(indicator);

    How can I access this checkbox on the client side to work with it.  Here is my client side code where I need to work with this checkbox

     

     

    for (var i=0; i < nodes.length; i++)

     

    {

        if (nodes[i].get_value() == selectedSubstanceId)

     

        {

                checkbox = nodes[i].findControl(

    "chkSource");

     

     

        }
    }

    the rest of the logic is working fine I just can't get the checkbox to work with it.
    the findControl returns null.

    Any help to figure this out is greatly appreciated.

    Thanks

    John

     

  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 13 Mar 2009 Link to this post

    Hello John,

    You can use the built-in checkbox support in RadTreeView.
    Then you can use the get_checkBoxElement method of RadTreeNode to obtain a reference to the Input element.

    Please check these links:
    I hope this helps.
    Sincerely yours,
    Veselin Vasilev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. John
    John avatar
    6 posts
    Member since:
    Jun 2008

    Posted 13 Mar 2009 Link to this post

    But is there anyway to make the built-in checkbox visible to but not clickable by the user (so they can't change it from checked to unchecked or unchecked to checked)?  This is the requirement I have in my program requirements.

    Thanks
    John
  4. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 16 Mar 2009 Link to this post

    Hi John,

    You have two alternatives to achieve that. Please choose one of options below:

    • Subscribe to the OnClientNodeChecking and cancel the event.
    • Iterate all nodes and set their disabled attribute to disabled:
        //sender is a reference to the RadTreeView object 
        var nodes = sender.get_allNodes(); 
        for (var i = 0; i < nodes.length; i++) 
        { 
            var checkbox = nodes[i].get_checkBoxElement(); 
            checkbox.disabled = "disabled"
        } 

    I hope this helps.
    Greetings,
    Veselin Vasilev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top