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

Change the visibility of item template

3 Answers 104 Views
OrgChart
This is a migrated thread and some comments may be shown as answers.
Alaa'
Top achievements
Rank 1
Alaa' asked on 14 Apr 2014, 09:09 AM
Hi,
in my org chart i add two  item template (DeleteBtn,PopUpBtn) 
item (DeleteBtn) want to be visible on last level node and item (PopUpBtn) visible on parents node 
how can i do it after binding data from database ?? 

and the item (Name) not always take the same (Container.DataItem) i want to change it at binding the data 

should I add the template at run time or how ?? 
<telerik:RadOrgChart ID="AdminOccupationsChart"  runat="server" LoadOnDemand="NodesAndGroups" EnableCollapsing="true"
                                        EnableDragAndDrop="true"   >
                                               <ItemTemplate>                                             
                                            <strong id="Name"> <%# DataBinder.Eval(Container.DataItem, "RecordName")%></strong>
                                            <button id="DeleteBtn"  title="Remove" class="rocRemoveItemButton"  />
                                            <button id="PopUpBtn" title="Open" class="rocOpenPopupButton"  />
                                        </ItemTemplate>
                              </telerik:RadOrgChart>

3 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 16 Apr 2014, 04:09 PM
Hello,

An easy and convenient way of applying different template to a specific org chart node would be using some server-side code in your markup code as shown in the sample code snippet:
//markup code
<telerik:RadOrgChart runat="server" ID="RadOrgChart1" Skin="Default" OnNodeDataBound="RadOrgChart1_NodeDataBound">
    <ItemTemplate>
        <strong><%# Container.Text == "Dimitar Berbatov" ? "LastItem" : "" %></strong>
        <strong><%# Container.Text == "David de Gea" ? "FirstItem" : "" %></strong>
    </ItemTemplate>
    <Nodes>
        <telerik:OrgChartNode>
            <RenderedFields>
                <telerik:OrgChartRenderedField Text="GoalKeeper" />
            </RenderedFields>
            <GroupItems>
                <telerik:OrgChartGroupItem Text="David de Gea" />
            </GroupItems>
            <Nodes>
                <telerik:OrgChartNode>
                    <RenderedFields>
                        <telerik:OrgChartRenderedField Text="Defence" />
                    </RenderedFields>
                    <GroupItems>
                        <telerik:OrgChartGroupItem Text="Rio Ferdinand" />
                        <telerik:OrgChartGroupItem Text="Phil Jones" />
                        <telerik:OrgChartGroupItem Text="Nemanja Vidic" />
                        <telerik:OrgChartGroupItem Text="Patrice Evra" />
                    </GroupItems>
                    <Nodes>
                        <telerik:OrgChartNode>
                            <RenderedFields>
                                <telerik:OrgChartRenderedField Text="Midfielders" />
                            </RenderedFields>
                            <GroupItems>
                                <telerik:OrgChartGroupItem Text="Ashley Young" />
                                <telerik:OrgChartGroupItem Text="Michael Carrick" />
                                <telerik:OrgChartGroupItem Text="Ryan Giggs" />
                                <telerik:OrgChartGroupItem Text="Ji-sung Park" />
                            </GroupItems>
                            <Nodes>
                                <telerik:OrgChartNode>
                                    <RenderedFields>
                                        <telerik:OrgChartRenderedField Text="Strikers" />
                                    </RenderedFields>
                                    <GroupItems>
                                        <telerik:OrgChartGroupItem Text="Wayne Rooney" />
                                        <telerik:OrgChartGroupItem Text="Dimitar Berbatov" />
                                    </GroupItems>
                                </telerik:OrgChartNode>
                            </Nodes>
                        </telerik:OrgChartNode>
                    </Nodes>
                </telerik:OrgChartNode>
            </Nodes>
        </telerik:OrgChartNode>
    </Nodes>
</telerik:RadOrgChart>

This code snippet will apply bold text "First Item" to the first org chart node and "Last Item" to the org chart last node.

Regards,
Boyan Dimitrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Alaa'
Top achievements
Rank 1
answered on 17 Apr 2014, 06:27 AM
thank you for reply :) 
ok this for the item template (Name) it work ,, what about the buttons ? (DeleteBtn) and (PopUpBtn) 
0
Plamen
Telerik team
answered on 21 Apr 2014, 10:40 AM
Hi,

At my side it worked correctly with the buttons too:
<button id="DeleteBtn"  title="Remove" class="rocRemoveItemButton"  ><%# Container.Text == "Dimitar Berbatov" ? "LastItem" : "" %></button>
          <button id="PopUpBtn" title="Open" class="rocOpenPopupButton"  ><%# Container.Text == "David de Gea" ? "FirstItem" : ""%></button>

Hope this will be helpful.

Regards,
Plamen
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
OrgChart
Asked by
Alaa'
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Alaa'
Top achievements
Rank 1
Plamen
Telerik team
Share this question
or