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

Add Hidden Fields to OrgChart Node/Group Item

1 Answer 126 Views
OrgChart
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 09 Aug 2018, 01:03 PM

Hi,

I have created an OrgChart and added a rendered field using RadOrgChart.RenderedFields.ItemFields.Add().

Is there a suitable way that I can add additional data to each Node/Group Item in the OrgChart without displaying it to the user and be able to access it from the client-side? Could this be done through a hidden field or through additional rendered fields?

Thanks,

Mark

1 Answer, 1 is accepted

Sort by
0
Peter Milchev
Telerik team
answered on 14 Aug 2018, 07:40 AM
Hello Mark,

If the information needed for the nodes is in the DataItem, you can access it in the item template as explained in https://docs.telerik.com/devtools/aspnet-ajax/controls/orgchart/templates/overview:

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

If you add the additional information in a HiddenField in the ItemTemplate, you can access it on the client-side as follows. 

var valueOfHiddenField = $telerik.$(nodeClientSideObject._element).find("[id$='_AdditionalInfo']").val();

<ItemTemplate>
    <span><%#Eval("EmployeeID")%></span>
    <br />
    <span><%#DataBinder.Eval(Container.DataItem, "ReportsTo")%></span>
    <br />
    <span><%#DataBinder.Eval(Container.DataItem, "FullName")%></span>
    <asp:HiddenField runat="server" ID="AdditionalInfo" Value=' <%#Eval("EmployeeID")%>' />
</ItemTemplate>

To access the HiddenField in the NodeDataBound event you can try this code: 

protected void RadOrgChart1_NodeDataBound(object sender, OrgChartNodeDataBoundEventArguments e)
{
    var node = e.Node;
    var hidden = node.Renderer.Controls[0].Controls[0].FindControl("AdditionalInfo") as HiddenField;
}

Regards,
Peter Milchev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
OrgChart
Asked by
Mark
Top achievements
Rank 1
Answers by
Peter Milchev
Telerik team
Share this question
or