Populate nodes in Telerik RadTreeview in Batch mode

2 posts, 0 answers
  1. mohmedsadiq modan
    mohmedsadiq modan avatar
    26 posts
    Member since:
    May 2010

    Posted 06 Sep 2012 Link to this post

    have Implemented telerik Tree-view in page and populating node using web-service.
    Source code look like
    <telerik:RadTreeView ID="tvNodes" runat="server" EnableDragAndDrop="false" ExpandAnimation-Type="OutExpo" ExpandAnimation-Duration="800" EnableDragAndDropBetweenNodes="false" CollapseAnimation-Type="OutElastic" CollapseAnimation-Duration="800" Skin="Windows7" OnNodeDrop="tvNodes_HandleDrop" ClientNodePopulating="nodePopulating">
               <telerik:RadTreeViewContextMenu ID="NodesTreeMenu" runat="server" CssClass="MenuGroup" Skin="Windows7">
                   <CollapseAnimation Type="none" />
           <WebServiceSettings Path="../ManageNode.asmx" Method="GetNodes">
    function nodePopulating(sender, eventArgs) {
           var node = eventArgs.get_node();
           var context = eventArgs.get_context();
           SelectedType = '1'//selected node id.
           SearchText = ''
           context["ParentID"] = node.get_value();
           context["AllowDragAndDrop"] = allowDragDrop;
           context["SelectedType"] = SelectedType;
           context["SearchText"] = SearchText;
       public RadTreeNodeData[] GetNodes(RadTreeNodeData node, object context)
           IDictionary<string, object> contextDictionary = (IDictionary<string, object>)context;
           List<RadTreeNodeData> nodes = new List<RadTreeNodeData>();
           int parentID = Convert.ToInt32(contextDictionary["ParentID"]);
           bool AllowDragAndDrop = Convert.ToBoolean(contextDictionary["AllowDragAndDrop"]);
           int selectedType = Convert.ToInt32(contextDictionary["SelectedType"]);
           string SearchText = Convert.ToString(contextDictionary["SearchText"]);
           dsNodes = NodeBLL.GetAllRecordsByNodeDefinition(selectedType, parentID, SearchText.Trim());
           for (int rowCount = 0; rowCount < dsNodes.Tables[0].Rows.Count; rowCount++)
               DataRow childRow = dsNodes.Tables[0].Rows[rowCount];
               RadTreeNodeData childNode = new RadTreeNodeData();
               if (Convert.ToInt16(childRow["StatusID"]) == Convert.ToInt16(Common.NodeStatus.Archieve))
                   childNode.Text = Common.DecodeXML(Convert.ToString(childRow["Name"])) + Common.deleteFlag;
                   childNode.Text = Common.DecodeXML(Convert.ToString(childRow["Name"]));
               childNode.Value = Convert.ToString(childRow["ID"]);
               childNode.Attributes.Add(Common.virtualIDAtt, Convert.ToString(childRow["virtualID"]));
               childNode.Attributes.Add(Common.isVirtualExist, Convert.ToString(childRow["isVirtualExist"]));
               childNode.Attributes.Add(Common.NodeDefinitionID, Convert.ToString(childRow["NodeDefinitionID"]));
               childNode.Attributes.Add(Common.ParentNodeID, Convert.ToString(childRow["ParentID"]));
               childNode.Attributes.Add(Common.Position, Convert.ToString(childRow["Position"]));
               childNode.Attributes.Add(Common.NodeDefinition, Convert.ToString(childRow["NodeDefinition"]));
               childNode.ExpandMode = (Convert.ToInt32(childRow["ischildexists"]) > 0) ? TreeNodeExpandMode.WebService : TreeNodeExpandMode.ClientSide;
        return nodes.ToArray();
    When I click on expand arrow then through javascript function web method is called to populate child node, it's worked perfect, I have issue in performance when parent node have 1000+ child nodes, I want to implement in batch mode like when user click on expand arrow then load 200 child node with more button then click on more button then load next 200 node. can any one have idea to achieve this feature.

  2. Plamen
    Plamen avatar
    2724 posts

    Posted 11 Sep 2012 Link to this post

    Hello Mohmedsadiq,

    I am attaching a sample project that implements similar functionality with RadTreeView based on our on-line demo.

    Hope this will be helpful.

    All the best,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. DevCraft R3 2016 release webinar banner
Back to Top