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

Dynamically loading a RadEditor control into a RadTreeNode

1 Answer 79 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Paul Robertson
Top achievements
Rank 1
Paul Robertson asked on 26 Aug 2011, 03:05 PM
Hi there

Can anyone point me in the right direction with a problem that has so far stumped me? I have a RadTreeView that uses an .ascx User Control as its node template, and which displays data from a hierarchical data source - the data is a hierarchical set of 'comments' submitted by users for a blog post. All this works fine. The issue is, I am trying to work out the best way of dynamically incorporating into a node an editor control which would be displayed ONLY if a new comment needed to be added as a 'reply' to an existing comment. In other words, I'm looking for a way to only display a text area editor in a node if the 'Reply' button is pressed for a particular node. Obviously I could have a RadEditor hidden within each node template, to be shown only as and when the Reply button is pressed. BUT ... this would mean having a RadEditor control for each and every node in the treeview, and I'm pretty sure this would have rather severe performance implications. I have many many nodes, and dread to think how slow it would be to have a RadEditor control instantiated server-side for each and every node.

At the moment I just have a single RadEditor outside the treeview hierarchy, but this is not ideal as it means the reply text area is at a different place on the page to the comment in question to which the reply is being made. Instead I'm looking for a way to do something like the review pages of Amazon, which appear to re-use a single control at different positions in the comment hierarchy dynamically on demand - I haven't really managed to reverse engineer their technique yet, it seems quite complex, but it appears to involve having a single 'pre-rendered' text area/editor hidden on the page, which is then dynamically injected into the tree view at the correct location by client-side Javascript, using a Placeholder that IS already included in the node template they use (I appreciate they may well not be using the RadTreeView control, but it is something similiar). 

So my question is, are there any additional RadControls that I should be using in order to reproduce this behaviour, or what would be the recommended technique for dynamically re-using and repositioning a single editor control within the tree view hierarchy as a whole, in a way that would avoid having a RadEditor control instantiated for every single node.

Thanks very much for your advice.

Regards



1 Answer, 1 is accepted

Sort by
0
Dimitar Terziev
Telerik team
answered on 31 Aug 2011, 02:45 PM
Hi Paul,

My suggestion is to make a post-back when you click the Replay button and upon button click to add RadEditor which you could use to edit the replays.

The benefit from this approach is that once you make another post-back this control won't be available in the controls collection. The drawback is that you should make a post-back, but you could use ajax to make the user experience smoother.

All the best,
Dimitar Terziev
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
TreeView
Asked by
Paul Robertson
Top achievements
Rank 1
Answers by
Dimitar Terziev
Telerik team
Share this question
or