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

Load on-demand - Hide checkBox

1 Answer 73 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Barbaros Saglamtimur
Top achievements
Rank 1
Barbaros Saglamtimur asked on 07 Mar 2011, 12:16 PM
Hi,

I have a radtreeview with load on-demand functionality and works fine.
What I would like to do is to hide checkbox for nodes which have child nodes count > 0. For root data it works, but not for child nodes.

Here is my code:

private static void LoadRootNodes(RadTreeView treeView, TreeNodeExpandMode expandMode)
    {
    .
    .
    .
        foreach (var row in sdps)
        {
            RadTreeNode node = new RadTreeNode
                                   {
                                       Text = row.FullText,
                                       Value = row.id.ToString(),
                                       ExpandMode = expandMode
                                   };
            node.Attributes.Add("IdAsText", row.IdAsText);
            if (row.ChildrenCount== 0)
            {
                node.ExpandMode = TreeNodeExpandMode.ClientSide;
            }
            else
            {
        //This works because RadTreeNode has a Checkable propery
                node.Checkable = false;
            }
            treeView.Nodes.Add(node);
        }
    }
 
 
   [WebMethod]
    public static RadTreeNodeData[] LoadSdpTreeView(RadTreeNodeData node)
    {
    .
    .
    .
        List<RadTreeNodeData> result = new List<RadTreeNodeData>();
        foreach (var row in childNodes)
        {
            RadTreeNodeData childNode = new RadTreeNodeData { Text = row.FullText, Value = row.id.ToString() };
            childNode.Attributes.Add("IdAsText", row.IdAsText);
            if (row.ChildrenCount > 0)
            {
                childNode.ExpandMode = TreeNodeExpandMode.WebService;
        // This doesnt work because there is no Checkable propery for RadTreeNodeData
        // childNode.Checkable = false;
            }
 
            result.Add(childNode);
        }
 
        return result.ToArray();
    }

How can I achieve this?

Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Nikolay Tsenkov
Telerik team
answered on 14 Mar 2011, 04:28 PM
Hi barbaros saglamtimur,

You can use the attributes collection in order to send to the client information about the Checkable property of the nodes. Here is a nice article that explains how you can get access to the attributes collection: http://www.telerik.com/help/aspnet-ajax/treeview-attributes-client-side.html


Regards,
Nikolay Tsenkov
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
TreeView
Asked by
Barbaros Saglamtimur
Top achievements
Rank 1
Answers by
Nikolay Tsenkov
Telerik team
Share this question
or