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

Add Button to Node

6 Answers 122 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 2
Mike asked on 01 Jun 2009, 07:51 PM
Hi Guys,

Can you add a button to a treeview node?

I need to give my client the ability fire an event on a specific node, but nice I have various other functionality tied into the tree already I don't really want to add a button below the tree to provide this event.

So...  Can I have a node like this.

Node Text  - (Button)

When the user clicks a button next to the node it fires off an event.  Maybe the button would select the node so I could get the info off the node tag.

Let me know.

~Mike

6 Answers, 1 is accepted

Sort by
0
Victor
Telerik team
answered on 02 Jun 2009, 12:52 PM
Hello Mike,

Thank you for writing. Please specify exactly what is your case. What kind of event do you need? Maybe we can add this event directly in RadTreeView in future. I have the feeling that you can proceed fine without a button. I am looking forward to your reply.

Best wishes,
Victor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Mike
Top achievements
Rank 2
answered on 02 Jun 2009, 02:38 PM
Hi Victor,

Let me setup the screen for you…

The user is presented a list of documents in a treeview.  They can re-order the documents via drag & drop (one or many), delete them from the list (one or many), or denote them as a special document type (one or many – special type also changes the node icon).

Each one of these functionalities are currently being handled via buttons below the treeview.  So if the user decides to re-order they would update the DB via the update order button.  If they want to delete one or several documents they select the item(s) and click the delete button (updates DB).  If they want to denote the document as a special type they select one or several and click the type button (updates DB).

With the new requested functionality the user wanted to have an ‘edit’ button next to a specific document type that meet certain criteria.  IE:  Only document types of ‘endorsement’ that are in ‘released’ status would see an edit button next to the node.

When the user clicks the ‘edit’ button we do a bunch of magic that would remove the current document, and replace it with a new document with a status of ‘work in progress’.

Now, with that said, I could easily add another button below the treeview that would handle this functionality – figure out what node was selected, remove it, add a new node, and do the document creation process.  But, if there was a way to add a button next to the node text it would save me a lot of checking to see if the node is the correct document type and status, before I process.  Also, it would also stop me from having to check if they selected many documents – this functionality can only be performed on one document at a time.

I hope I made myself clear.

~Mike

0
Victor
Telerik team
answered on 05 Jun 2009, 03:47 PM
Hello Mike,

Thank you for the in-depth explanation. In order to place a button next to the nodes, you will have to inherit RadTreeView and modify its layout. But that will be hard to do so I suggest creating a context menu for each node and adding options in it depending on your criteria. Here is how you can associate a context menu to a RadTreeNode. The first node in this example:

RadDropDownMenu menu = new RadDropDownMenu();  
menu.Items.Add(new RadMenuItem("Action1"));  
menu.Items.Add(new RadMenuItem("Action2"));  
menu.Items.Add(new RadMenuItem("Action3"));  
this.radTreeView1.Nodes[0].ContextMenu = menu; 

The only thing left to do is to subscribe to the Click event of each menu item and perform the needed actions. Also if you want to disable a menu item you have to set its Enabled property to false. Do not hesitate to write back if you need further assistance.

Sincerely yours,
Victor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Srikanth
Top achievements
Rank 1
answered on 23 Jul 2010, 05:25 AM
Hi Victor,


i have to add Button to each  node in the Tree view. if i click the button,i have to open popup using Radwindow. Please give an idea how to add Button to each node.

Thanks and Regards,
Srikanth.
0
Victor
Telerik team
answered on 28 Jul 2010, 01:12 PM
Hi Srikanth,

Thank you for writing.

As I stated in my previous post RadTreeView does not support custom elements in its nodes, your best bet is to use a context menu that is specific for each node.

Write again if you have other questions.

Regards,
Victor
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Stefan
Telerik team
answered on 22 Mar 2011, 02:42 PM
Hi Mike,

Please note that in Q1 2011 we have introduced a major upgrade of RadTreeView control, which is now virtualized and fully customizable. Feel free to download the latest release and try it out. For more information on our latest release refer to this blog post.
 
Best wishes,
Stefan
the Telerik team
Tags
Treeview
Asked by
Mike
Top achievements
Rank 2
Answers by
Victor
Telerik team
Mike
Top achievements
Rank 2
Srikanth
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or