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

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

1 Answer 84 Views
TileList
This is a migrated thread and some comments may be shown as answers.
Saravanan
Top achievements
Rank 1
Saravanan asked on 04 Jun 2013, 04:55 AM
Hi,
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"/>
                            </ClientSettings>
 
                            <Columns>
                                <telerik:TreeListEditCommandColumn   UniqueName="InsertCommandColumn"  ShowAddButton="false" ButtonType="ImageButton" ShowEditButton="false" HeaderStyle-Width="30px" ItemStyle-HorizontalAlign="Center">
                                     <HeaderStyle Width="60px" />
                                    <ItemStyle Width="60px" />
                                </telerik:TreeListEditCommandColumn>
                                <telerik:TreeListButtonColumn CommandName="Edit" Text="Edit" UniqueName="EditCommandColumn" ButtonType="ImageButton" HeaderStyle-Width="30px" ItemStyle-HorizontalAlign="Center">
                                    
                                </telerik:TreeListButtonColumn>
 
                                <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;
                    break;
                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"));
                    break;
                case 2:
                    item.BackColor = System.Drawing.Color.LightPink;
                    item["InsertCommandColumn"].Visible = true;
                    break;
            }
        }
    }

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 07 Jun 2013, 05:29 AM
Hi,

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.

Regards,
Andrey
Telerik
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.
Tags
TileList
Asked by
Saravanan
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or