How to remove Plus(Add) button from Parent Node In the Code Behind? or Enable the Plus(Add) button the child nodes?

2 posts, 0 answers
  1. Saravanan
    Saravanan avatar
    3 posts
    Member since:
    Dec 2012

    Posted 03 Jun 2013 Link to this post

    How to access the TreeListEditCommandColumn in the code behind. I was trying to access from code behind, but i could not able to acess.
    Please help me out.Please refer the below code for your reference.

    If i can acces the

    TreeListEditCommandColumn , from that i can able to hide the plus button in the parent node. or i can set the visible true/false.

    <telerik:RadTreeList ID="treeListClientBudget" runat="server" OnNeedDataSource="treeListClientBudget_NeedDataSource" Visible="false" HideExpandCollapseButtonIfNoChildren="true"
                                DataKeyNames="DataKey" Height="200px" OnChildItemsDataBind="treeListClientBudget_ChildItemsDataBind" OnItemDataBound="treeListClientBudget_ItemDataBound"
                                ParentDataKeyNames="ParentKey" AutoGenerateColumns="false" AllowLoadOnDemand="true" EditMode="InPlace" OnUpdateCommand="treeListClientBudget_UpdateCommand" OnInsertCommand="treeListClientBudget_InsertCommand" OnCancelCommand="treeListClientBudget_CancelCommand" OnEditCommand="treeListClientBudget_EditCommand">
                                <ClientSettings Selecting-AllowItemSelection="true" Scrolling-AllowScroll="true" Scrolling-UseStaticHeaders="true" >
                                    <Selecting AllowToggleSelection="true"/>
                                    <telerik:TreeListEditCommandColumn   UniqueName="InsertCommandColumn"  ShowAddButton="false" ButtonType="ImageButton" ShowEditButton="false" HeaderStyle-Width="30px" ItemStyle-HorizontalAlign="Center">
                                         <HeaderStyle Width="60px" />
                                        <ItemStyle Width="60px" />
                                    <telerik:TreeListButtonColumn CommandName="Edit" Text="Edit" UniqueName="EditCommandColumn" ButtonType="ImageButton" HeaderStyle-Width="30px" ItemStyle-HorizontalAlign="Center">
                                    <telerik:TreeListButtonColumn UniqueName="DeleteCommandColumn" Text="Delete" CommandName="Delete" ButtonType="ImageButton" HeaderStyle-Width="30px"></telerik:TreeListButtonColumn>
                                    <telerik:TreeListBoundColumn DataField="DisplayName" UniqueName="DisplayName" ReadOnly="true"
                                        HeaderText="Month/Classification">   </telerik:RadTreeList>


    please refer the code for Codebehind .CS


    protected void treeListClientBudget_ItemDataBound(object sender, TreeListItemDataBoundEventArgs e)
            if (e.Item is TreeListDataItem)
                TreeListDataItem item = e.Item as TreeListDataItem;
                //hdnClassificationId.Value = Convert.ToString(item.GetDataKeyValue("DataKey"));
                switch (item.HierarchyIndex.NestedLevel)
                    case 0:
                        item.BackColor = System.Drawing.Color.LightYellow;
                    case 1:
                        item.BackColor = System.Drawing.Color.YellowGreen;
                        ImageButton treelist = item["TreeListEditCommandColumn"].FindControl("InsertCommandColumn") as ImageButton;
                        //treelist.ShowAddButton = true;
                        //    hdnClassificationId.Value =Convert.ToString( item.GetDataKeyValue("DataKey"));
                    case 2:
                        item.BackColor = System.Drawing.Color.LightPink;
                        item["InsertCommandColumn"].Visible = true;
  2. Andrey
    Andrey avatar
    836 posts

    Posted 07 Jun 2013 Link to this post


    In order to achieve your goal you should use the approach described in this help topic. Additionally, FindControl is used to find instances of types derived from WebControl, it could not be used to find columns.

    Give the approach from the help topic a try and you should succeed.

    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. DevCraft R3 2016 release webinar banner
Back to Top