Set CheckAll checkbox value from server or client

14 posts, 0 answers
  1. Bob
    Bob avatar
    46 posts
    Member since:
    Apr 2012

    Posted 02 May 2014 Link to this post

    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
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 05 May 2014 in reply to Bob Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Bob
    Bob avatar
    46 posts
    Member since:
    Apr 2012

    Posted 05 May 2014 in reply to Shinu Link to this post

    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
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 05 May 2014 in reply to Bob Link to this post

    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.
  6. Bob
    Bob avatar
    46 posts
    Member since:
    Apr 2012

    Posted 06 May 2014 in reply to Shinu Link to this post

    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
  7. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 06 May 2014 in reply to Bob Link to this post

    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.
  8. Bob
    Bob avatar
    46 posts
    Member since:
    Apr 2012

    Posted 07 May 2014 in reply to Shinu Link to this post

    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
  9. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 07 May 2014 in reply to Bob Link to this post

    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.
  10. Bob
    Bob avatar
    46 posts
    Member since:
    Apr 2012

    Posted 08 May 2014 in reply to Shinu Link to this post

    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
  11. Bob
    Bob avatar
    46 posts
    Member since:
    Apr 2012

    Posted 08 May 2014 Link to this post

    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
  12. Bob
    Bob avatar
    46 posts
    Member since:
    Apr 2012

    Posted 08 May 2014 Link to this post

    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
  13. Bob
    Bob avatar
    46 posts
    Member since:
    Apr 2012

    Posted 08 May 2014 Link to this post

    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
  14. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 12 May 2014 Link to this post

    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.

     
  15. Bob
    Bob avatar
    46 posts
    Member since:
    Apr 2012

    Posted 12 May 2014 in reply to Nencho Link to this post

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