ASPxTreeList.CommandColumnButtonInitialize Event

Enables individual command buttons to be initialized.

Namespace: DevExpress.Web.ASPxTreeList

Assembly: DevExpress.Web.ASPxTreeList.v19.2.dll

Declaration

public event TreeListCommandColumnButtonEventHandler CommandColumnButtonInitialize
Public Event CommandColumnButtonInitialize As TreeListCommandColumnButtonEventHandler

Event Data

The CommandColumnButtonInitialize event handler receives an argument of the TreeListCommandColumnButtonEventArgs type. The following properties provide information specific to this event.

Property Description
ButtonType Gets the type of the command button currently being initialized.
CommandColumn Gets a command column which owns the processed command button.
CustomButtonIndex Gets the processed command button's index.
Enabled Gets or sets whether the processed command button is enabled.
NodeKey Gets the key of a node which contains the processed command button.
Visible Gets or sets whether the command button is visible.

Remarks

The CommandColumnButtonInitialize event is raised for each command button (edit, new, delete, etc.), and allows their settings to be initialized. For instance, you can hide or disable individual command buttons.

Examples

This example illustrates how to hide the delete button for those nodes that have child nodes in the CommandColumnButtonInitialize event handler.

<dx:ASPxTreeList ID="ASPxTreeList1" runat="server" AutoGenerateColumns="False" DataSourceID="AccessDataSource1"
    KeyFieldName="EmployeeID" ParentFieldName="ReportsTo" 
    EnableCallbacks="true" 
    oncommandcolumnbuttoninitialize="ASPxTreeList1_CommandColumnButtonInitialize" 
    onnodedeleting="ASPxTreeList1_NodeDeleting">
    <Columns>
        <dx:TreeListTextColumn FieldName="LastName" VisibleIndex="0">
        </dx:TreeListTextColumn>
        <dx:TreeListTextColumn FieldName="FirstName" VisibleIndex="1">
        </dx:TreeListTextColumn>
        <dx:TreeListTextColumn FieldName="Title" VisibleIndex="2">
        </dx:TreeListTextColumn>
        <dx:TreeListCommandColumn VisibleIndex="3">
            <DeleteButton Visible="True">
            </DeleteButton>
        </dx:TreeListCommandColumn>
    </Columns>
    </dx:ASPxTreeList>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/nwind.mdb"
    DeleteCommand="DELETE FROM [Employees] WHERE [EmployeeID] = ?" InsertCommand="INSERT INTO [Employees] ([EmployeeID], [LastName], [FirstName], [Title], [ReportsTo]) VALUES (?, ?, ?, ?, ?)"
    SelectCommand="SELECT [EmployeeID], [LastName], [FirstName], [Title], [ReportsTo] FROM [Employees]"
    UpdateCommand="UPDATE [Employees] SET [LastName] = ?, [FirstName] = ?, [Title] = ?, [ReportsTo] = ? WHERE [EmployeeID] = ?">
    <DeleteParameters>
        <asp:Parameter Name="EmployeeID" Type="Int32" />
    </DeleteParameters>
    <UpdateParameters>
        <asp:Parameter Name="LastName" Type="String" />
        <asp:Parameter Name="FirstName" Type="String" />
        <asp:Parameter Name="Title" Type="String" />
        <asp:Parameter Name="ReportsTo" Type="Int32" />
        <asp:Parameter Name="EmployeeID" Type="Int32" />
    </UpdateParameters>
    <InsertParameters>
        <asp:Parameter Name="EmployeeID" Type="Int32" />
        <asp:Parameter Name="LastName" Type="String" />
        <asp:Parameter Name="FirstName" Type="String" />
        <asp:Parameter Name="Title" Type="String" />
        <asp:Parameter Name="ReportsTo" Type="Int32" />
    </InsertParameters>
</asp:AccessDataSource>
See Also