In RadTreeView, I want to add an image at right side of the node text for all the nodes in Client- Side.
Description:
1. Dynamically, I am adding nodes in the client side and here I wanted to place an image at right side of the node text(find attached for how I wanted) and I tried with "farimage" property, Image index property as the value of "1" and tried with many ways. But, all are not working out.
In one way, I am able to achieve this, If I append an image with the text. But, I am getting an error ("A potentially dangerous Request.Form value was detected from the client ") while post occurs.
I would be helpful if you send me an example.
9 Answers, 1 is accepted
One suggestion is that, you can add the image in the NodeTemplate as shown below.
aspx:
<
NodeTemplate
>
<
img
src
=
"Images/img1.gif"
/>
</
NodeTemplate
>
-Shinu.
Thanks for your reply.
I am adding node values dynamically as follows,
childNode.set_text(newarray[newarray.length - 1].get_text());
in this case, I am able add an image at the left of the node text but not at the right side of the node text.
Thanks & Regards
Ubahariya
You can change the place of the image with jQuery as in the code bellow:
function
pageLoad() {
$ = $telerik.$;
var
first = $(
".rtImg"
).each(
function
(a) {
$(
this
).parent().append($(
".rtImg"
)[a]);
});
}
Hope this will be helpful.
Kind regards,
Plamen Zdravkov
the Telerik team
I had tried
Dim sourceNode As RadTreeNode = RadTreeView1.Nodes(0).Nodes(1).Nodes.FindNodeByText("Celular 1")
Dim x As New RadTreeNode
x.ImageUrl = "~/images/campoTexto.jpg"
Dim A As New Label
A.Text = "TEST "
Dim B As New HtmlImage
B.Src = "~/images/camera.jpg"
Dim C As New HtmlImage
C.Src = "~/images/video.png"
x.Controls.Add(A)
x.Controls.Add(B)
x.Controls.Add(C)
sourceNode.InsertAfter(x)
All images have the same size.
As you can see, this new node became unaligned
You can refer to the Adding and Editing Templates at Runtime help topic, where is shown one way such functionality can be handled.
Hope this will be helpful.
Plamen Zdravkov
the Telerik team
Hi,
As per your comments, there is an possibility to add an image on left side based on the condition. Could you please share all the codes relate to the left side image dynamically.
Currently Iam able to hardcore the leftside image on RAD Treeview. But i want to display the left side image based on some condition from c#.
Could you please help.
One possible way is to use the DataBinding event of the control added as for example it is done with the label and the label1_DataBinding event and set the Image based on the text or value of the node.
Regards,
Plamen
Telerik by Progress
I have a treenode and a link button as shown below. And I'm showing the div which contains link button in Client data bound event of tree view.
Problem here is link is not aligned in the same line for parent and child tree nodes. How can I fix the position of link same in all the nodes even while expanding.
<Nodes>
<telerik:RadTreeNode Width="20%" Text="Medispan Categories" ExpandMode="WebService" >
</telerik:RadTreeNode>
</Nodes> </telerik:RadTreeView>
<div id="templateForMedispan" class="sys-template">
<div style="float:right;width:60%"><a href="javascript:void(0);" onclick="{{'ShowDrugsFor(\'' + Code + '\',\'F\')' }}">View</a></div>
</div>
The code provided is not enough to replicate the issue. The scenario itself seems to be rather connected with a custom implementation than the control itself.
Regards,
Plamen
Telerik by Progress