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

Populate nodes in Telerik RadTreeview in Batch mode

1 Answer 116 Views
This is a migrated thread and some comments may be shown as answers.
mohmedsadiq modan
Top achievements
Rank 1
mohmedsadiq modan asked on 06 Sep 2012, 06:33 AM
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.


1 Answer, 1 is accepted

Sort by
Telerik team
answered on 11 Sep 2012, 06:43 AM
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.
Asked by
mohmedsadiq modan
Top achievements
Rank 1
Answers by
Telerik team
Share this question