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

Set CheckAll checkbox value from server or client

13 Answers 232 Views
DropDownTree
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 1
Bob asked on 02 May 2014, 08:49 PM
We have the ButtonSettings ShowCheckAll=true and it is showing up and working as expected in our UI.

However, we would like to conditionally set the checkbox value so all the checkboxes are already preselected.

We would like to do this from either server or client side.  How can this done?

We are currently running version 2013.2.717.40.

Thanks in advance.
Bob Baldwin
Trabon Solutions

13 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 05 May 2014, 06:34 AM
Hi Bob,

Please try the following C# code snippet to check all string based on condition.

C#:
foreach (RadTreeNode node in raddroptreeCheckAll.EmbeddedTree.Nodes)//accessing all root nodes of a tree
{
    //you can check the condition
    if (node.Checked == false? node.Checked=true: node.Checked=false) //check the root node
    if (node.GetAllNodes().Count != 0)
    {
        foreach (RadTreeNode subnode in node.GetAllNodes())//accessing child nodes of each root node
        {
            if (subnode.Checked == false)
                subnode.Checked = true;
        }
    }
}

Thanks,
Shinu.
0
Bob
Top achievements
Rank 1
answered on 05 May 2014, 06:09 PM
Thank you Shinu.

We now see that when all nodes are checked the All gets checked as well.

Another question please, when working in the server side NodeDataBound event we would like to make certain nodes disabled (unselectable) based on specific conditions.  We see how to set Checkable to false but do not see the Enabled property exposed on the DropDownTreeNode.  Is it possible to disable nodes while binding them with DropDownTree?

Thanks in advance....Bob Baldwin
Trabon Solutions
0
Shinu
Top achievements
Rank 2
answered on 06 May 2014, 04:22 AM
Hi Bob,

Please have a look into the following C# code snippet to disable the child nodes of a RadDropDownTree.

C#:
protected void raddroptreeCheckAll_NodeDataBound(object sender, Telerik.Web.UI.DropDownTreeNodeDataBoundEventArguments e)
{
    foreach (RadTreeNode node in raddroptreeCheckAll.EmbeddedTree.Nodes)
    {
        if (node.GetAllNodes().Count != 0)
        {
            foreach (RadTreeNode subnode in node.GetAllNodes())
            {
                subnode.Enabled = false;
            }
        }
    }
}

Thanks,
Shinu.
0
Bob
Top achievements
Rank 1
answered on 06 May 2014, 02:08 PM
Thanks but this does not seem to help us.

We already know how to access RadDropDownTree node properties in this way.

What we need is to be able to inspect the e.DropDownTreeNode.DataItem and conditionally enable or disable the current node being databound.  However, we cannot get access to the underlying node Enabled property within the NodeDataBound event.

Is there any way to get access to the underlying node during NodeDataBound because the e.DropDownTreeNode seems to be a stripped down version of the regular Node object.

Thanks...Bob Baldwin
Trabon Solutions
0
Shinu
Top achievements
Rank 2
answered on 07 May 2014, 03:57 AM
Hi Bob,

Please have a look into the sample code snippet to access a node in onNodeDataBound event and based on the condition make it as disabled.

C#:
protected void raddroptreeCheckAll_NodeDataBound(object sender, Telerik.Web.UI.DropDownTreeNodeDataBoundEventArguments e)
    {
        if (e.DropDownTreeNode.Text == "Politics")//checking the condition based on the text
        {
            RadTreeNode node = raddroptreeCheckAll.EmbeddedTree.Nodes.FindNodeByText(e.DropDownTreeNode.Text);
            node.Enabled = false;
        }
    }
}

Thanks,
Shinu.
0
Bob
Top achievements
Rank 1
answered on 07 May 2014, 03:34 PM
Hi Shinu,

Thank you for this code.  It worked, however, we're unable to use because we still need to expand disabled nodes.

Is there a way to get the OnClientNodeClicking event to work with RadDropDownTree?

Thanks....Bob Baldwin
Trabon Solutions
0
Shinu
Top achievements
Rank 2
answered on 08 May 2014, 02:55 AM
Hi Bob,

RadDropDownTree doesn't have OnClientNodeClicking event. Please have a look into this help documentation to know more about the client side events that RadDropDownTree supports. You can use anyone of it to achieve your scenario. Please elaborate your scenario for further help.

Thanks,
Shinu.
0
Bob
Top achievements
Rank 1
answered on 08 May 2014, 12:59 PM
Basically, when we display the tree of parent and children nodes within the dropdowntree we need some way to stop the user from "selecting" a parent node.  Meaning only a single child node can be "selected"  (we do not mean "checked").

Without the OnClientNodeClicking event being exposed even though the underlying embeddedtree is a RadTreeView it seems we are out of luck.

We will have to validate the selected node server side to make sure it is valid.  We were hoping to actively stop it in the UI or do some client side validation but it just does not seem possible.

Does this help you understand what we are trying to do?

Thanks...Bob Baldwin
Trabon Solutions
0
Bob
Top achievements
Rank 1
answered on 08 May 2014, 04:33 PM
Shinu,

I think an earlier post answered by Peter F. may be what we need.

http://www.telerik.com/forums/don-t-allow-parent-selection

I will let you know how it goes.

Thanks...Bob Baldwin
Trabon Solutions
0
Bob
Top achievements
Rank 1
answered on 08 May 2014, 04:35 PM
Hi Shinu,

It looks like an answer from an earlier post may be what we need.

http://www.telerik.com/forums/don-t-allow-parent-selection

I'll let you know how it goes.

Thx...Bob Baldwin
Trabon Solutions
0
Bob
Top achievements
Rank 1
answered on 08 May 2014, 04:36 PM
Hi Shinu,

It looks like an answer from an earlier post may be what we need.

[quote]http://www.telerik.com/forums/don-t-allow-parent-selection
[/quote]

I'll let you know how it goes.

Thx...Bob Baldwin
Trabon Solutions
0
Nencho
Telerik team
answered on 12 May 2014, 10:36 AM
Hello Bob,

You could handle the OnClientNodeChecking, by hooking the client-side event of the EmbeddedTree of the RadDropDownTree in the following manner for example:

protected void Page_Load(object sender, EventArgs e)
        {
            RadDropDownTree1.EmbeddedTree.OnClientNodeChecking = "OnClientNodeChecking";
        }


Regards,
Nencho
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Bob
Top achievements
Rank 1
answered on 12 May 2014, 01:06 PM
The following post worked perfectly, particularly the last response from Peter.  We needed to inspect the actual tree nodes versus the entries to see if they had any children.  Thank you all for your assistance with this.

http://www.telerik.com/forums/don-t-allow-parent-selection

Thanks...Bob Baldwin
Trabon Solutions
Tags
DropDownTree
Asked by
Bob
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Bob
Top achievements
Rank 1
Nencho
Telerik team
Share this question
or