Change the visibility of item template

4 posts, 0 answers
  1. Alaa'
    Alaa' avatar
    20 posts
    Member since:
    Apr 2014

    Posted 14 Apr 2014 Link to this post

    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>
  2. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 16 Apr 2014 Link to this post

    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Alaa'
    Alaa' avatar
    20 posts
    Member since:
    Apr 2014

    Posted 17 Apr 2014 in reply to Boyan Dimitrov Link to this post

    thank you for reply :) 
    ok this for the item template (Name) it work ,, what about the buttons ? (DeleteBtn) and (PopUpBtn) 
  5. Plamen
    Admin
    Plamen avatar
    2731 posts

    Posted 21 Apr 2014 Link to this post

    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.

     
Back to Top