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

Adding new child node to TreeView, then select it

1 Answer 106 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 31 Jan 2014, 12:02 AM
Hello all,

I am trying to bind a TreeView to a folder on the server - and I've got it working. The issue is that I would like to give users the ability to create their own folders. Through a javascript prompt, I'm able to get the new folder's name, and submit it via Ajax to a web service that creates the folder on the file system.

Where I'm stuck is adding the new node (folder) to the TreeView, and having it display. I got the javascript working, but sometimes it doesn't mark the new node as a directory (with a "plus" icon) - and sometimes it does. It's inconsistent (see attached image of a newly inserted node). Now if I refresh the page, the new folder appears correctly (with the "plus" icon).

I realize I'm binding to a physical directory on the server side, and then dynamically inserting a node on the client side - so maybe this is part of the problem. I'm just looking for a way to allow the user to create a folder, then have it added to the TreeView and selected (highlighted), with the ability to continue adding subfolders.

I'm okay with a page refresh - but so far I haven't been able to find a way to select a child node on the page load (I can select a top-level "root" folder, but it doesn't expand the tree to select the child node.

You can download mt test page here:

https://dl.dropboxusercontent.com/u/2316951/Web/telerik.zip

Thanks for any assistance!


 

1 Answer, 1 is accepted

Sort by
0
Hristo Valyavicharski
Telerik team
answered on 04 Feb 2014, 02:10 PM
Hi Robert,

Why don't you use the File Explorer control? It has a built-in support for adding/editing/removing files and folders.

Regards,
Hristo Valyavicharski
Telerik
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 UI for ASP.NET AJAX, subscribe to the blog feed now.
Tags
TreeView
Asked by
Robert
Top achievements
Rank 1
Answers by
Hristo Valyavicharski
Telerik team
Share this question
or