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

[Solved] TreeView Custom Attributes

1 Answer 202 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Zhengmao
Top achievements
Rank 1
Zhengmao asked on 23 Apr 2008, 03:00 PM

I loaded the treeview from SQL on code behind and add custom attributes there, 

<

telerik:RadTreeView ID="RadTreeView1" runat="server" OnNodeClick="RadTreeView1_NodeClick"

 

Skin="Default" Width="99%" Height="550px" OnClientContextMenuItemClicking="ContextMenuClick"

 

AllowNodeEditing="True" OnNodeEdit="RadTreeView1_NodeEdit" AccessKey="T" EnableDragAndDrop="True"

 

OnNodeDrop="RadTreeView1_NodeDrop" OnNodeExpand="RadTreeView1_NodeExpand" OnContextMenuItemClick="RadTreeView1_ContextMenuItemClick">

 

<ContextMenus>

 

<telerik:RadTreeViewContextMenu ID="treContextMenu" Skin="Vista" runat="server" CollapseAnimation-Duration="100">

 

<Items>

 

<telerik:RadMenuItem Text="Remote Desktop to Server" ImageUrl="Img/new.gif" ></telerik:RadMenuItem>

 

<telerik:RadMenuItem IsSeparator=true></telerik:RadMenuItem>

 

<telerik:RadMenuItem Text="New Node" ImageUrl="Img/new.gif" />

 

<telerik:RadMenuItem Text="Delete Node" ImageUrl="Img/delete.gif" />

 

<telerik:RadMenuItem Text="Rename Node" ImageUrl="Img/rename.gif" PostBack="false" />

 

<telerik:RadMenuItem Text="Copy Node" ImageUrl="Img/copy.gif" />

 

<telerik:RadMenuItem Text="Paste Node" ImageUrl="Img/paste.gif" />

 

</Items>

 

</telerik:RadTreeViewContextMenu>

 

</ContextMenus>

 

<NodeTemplate>

 

<asp:Image ID="imgSeverity" runat="server" ImageUrl="~/Images/greenfla.bmp" />

 

<asp:Image ID="ImgNode" runat="server" ImageUrl="~/Images/city.bmp" />

 

<asp:Label ID="lblNodeName" runat="server"></asp:Label>

 

<%

# DataBinder.Eval(Container.DataItem, "NodeName")%>

</NodeTemplate>

 

</telerik:RadTreeView>

serverNode.Attributes[

"Current_Severity"] = serverRow["Current_Severity"].ToString();

serverNode.Attributes[

"IP_Address"] = serverRow["IP_Address"].ToString();

when I tried to retrieve attrbitue from context menu client function, 

function ContextMenuClick(sender, eventArgs)

{

var node = eventArgs.get_node() ;

alert(node.get_text()) ;

var ip_Address = node.get_attributes().getAttribute("IP_Address");

var NodeType = node.get_attributes().getAttribute("NoteType");


if
(eventArgs.get_menuItem().get_text() == "Remote Desktop to Server")

{

runApp(ip_Address) ;

}

}


it told me that ip_address is undefined.

any Idea about it?

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 24 Apr 2008, 10:19 AM
Hi Zhengmao,

How do you populate the custom attributes on the server-side? Could you paste here your code? I suspect for some reason the custom attributes are not set for the nodes. You can try inspecting your code with a debugger to see if the code is populating those attributes.

Regards,
Albert
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
TreeView
Asked by
Zhengmao
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or