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

accessing checkbox in node on client side

3 Answers 96 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 12 Mar 2009, 09:11 PM

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

 

3 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 13 Mar 2009, 09:03 AM
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.
0
John
Top achievements
Rank 1
answered on 13 Mar 2009, 10:19 AM
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
0
Veselin Vasilev
Telerik team
answered on 16 Mar 2009, 11:59 AM
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.
Tags
TreeView
Asked by
John
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
John
Top achievements
Rank 1
Share this question
or