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

Can insert node w/ HTML into tree?

4 Answers 108 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Jay
Top achievements
Rank 1
Jay asked on 27 Aug 2008, 11:24 PM
Is there a way to insert a node (from the server-side) into a RadTreeView that contains HTML? For example ... how do I insert
SomeText<i>some other text</i> and have it show the "some other text" as italic (basically tell the server NOT to HTML encode the string)?

By default it HTML-encodes the Text property.

Thanks!
Jay

4 Answers, 1 is accepted

Sort by
0
Jay
Top achievements
Rank 1
answered on 29 Aug 2008, 01:19 AM
Ooops. My bad. This control requires the caller to HTML encode the string .... which is perfect. This way the caller can actually pass HTML tags into the tree.
0
Veselin Vasilev
Telerik team
answered on 29 Aug 2008, 09:58 AM
Hi Jay,

Yes, you can encode the string.

Alternatively, you can use Templates.

Greetings,
Veskoni
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jay
Top achievements
Rank 1
answered on 29 Aug 2008, 11:09 PM
Thanks ... the template idea is great.

I do believe I found a bug in the Javascript node.set_text() api.

It looks like you are HTML-Decoding the text that is passed. I do not believe this is what you intended to do with this API. For example, if I call
node.set_text("&lt;b&gt;Test Text&lt;/b&gt;")
or
node.set_text("<b>Test Text</b>")
they will both show the text bolded in the treeview.

I believe you should NOT be html-decodeing the string ... just pass it as-is to the tree control. Otherwise the caller must html-encode TWICE any string that should be displayed as text.

The server-side RadTreeNode.Text property works correctly ...
0
Veselin Vasilev
Telerik team
answered on 02 Sep 2008, 11:28 AM
Hello Jay,

This behavior is by design (we need it when editing a node).
You can use the get_textElement() method of the node and modify its innerHTML property with every string you want. That text will not be encoded/decoded, but will not persist after postback.


Regards,
Veskoni
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
TreeView
Asked by
Jay
Top achievements
Rank 1
Answers by
Jay
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Share this question
or