We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Dynamically Expandable TreeView Nodes

Thread ID:

Created:

Updated:

Platform:

Replies:

72982 Apr 14,2008 03:29 PM Apr 24,2008 10:34 AM ASP.NET Web Forms (Classic) 2
loading
Tags: Tools
Neal
Asked On April 14, 2008 03:29 PM

I have a TreeView with Nodes that are added in client-side code (I'm loading it with a list of drives/directories/files from the local file system). I want to dynamically load the contents of the directories dynamically, much like I've done with Server-side callback. However, if I select ExpandMode = TreeViewNodeExpandMode.ClientSide, the "+" doesn't appear next to the node. How can I get the "+" to appear in this case. Eventually, I want my ClientSideOnNodeExpand JScript function called when the user clicks on the "+"..


Neal
Replied On April 18, 2008 11:14 AM

Ok, I found a workaround. Whenever I create a folder, I also create a dummy node under it with text of "". Then, when the user expands the folder, I check for a single node with the above text. If it exists, I delete it and load the contents of the directory into the tree. I used the angle brackets above since they are not valid in a filename.

It seems like there should be a better way to accomplish this; but, this will do for now.



Janagan [Syncfusion]
Replied On April 24, 2008 10:34 AM


Hi Neal,

If your intention is to load the childnode dynamically by invoking the clientside javascript, it can be achieved via a callback panel but you cannot make the "+" sign to appear by setting the expandmode to client side because When the expand mode is set to Client side, any callback or postback will not occur on expanding node. Please refer the code below for dynamically loading the child node via callback panel:

function nodeExpand(node)
{

document.getElementById(''eventDisplay'').innerHTML = "Expanded ''" + node.Text + "''" ;
CallbackPanel1.callback(node.Text);
}

code behind:

protected void CallbackPanel1_CallbackRefresh(object sender, CancellableCallbackEventArgs e)
{
foreach (TreeViewNode node in this.TreeView1.Items)
{

if (node.Text == e.CallbackArgument)
{
TreeViewNode childnode = new TreeViewNode();
childnode.Text = "New Text";
node.Items.Add(childnode);
}



}
}



Please refer the sample in the link below which illustrates the above:

http://websamples.syncfusion.com/samples/Tools.Web/6.2.0.40/cs/main.htm

Please try running the sample and if still the issue exists, could you please try reproducing it in the above sample so that we could sort out the cause and provide you a better solution?

Regards,
Janagan.



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;