TreeListDataRowCommandContext.RowVisibleIndex Property
Returns the visible index of the target row.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v25.2.dll
NuGet Package: DevExpress.Blazor
Declaration
public int RowVisibleIndex { get; }
Property Value
| Type | Description |
|---|---|
| Int32 | A row visible index. |
Remarks
The DevExpress Blazor TreeList allows you to display context menus with predefined and custom commands. Use the ContextMenus property to activate context menus for specific TreeList elements. Handle the CustomizeContextMenu event to modify the menu item collection. Use the Context event argument to identify the target TreeList element and obtain contextual information.
When the target element is a data row cell, the Context property returns a TreeListDataRowCommandContext object. Use the object’s RowVisibleIndex property to obtain the target row’s visible index.
Example
The following code snippet adds a custom Delete command to the row context menu:
@inject EmployeeTaskService EmployeeTaskService
<DxTreeList Data="TreeListData"
KeyFieldName="Id"
ParentKeyFieldName="ParentId"
DataItemDeleting="OnDataItemDeleting"
ContextMenus="TreeListContextMenus.DataRow"
CustomizeContextMenu="CustomizeContextMenu">
<Columns>
<DxTreeListDataColumn FieldName="Name" Caption="Task" />
<DxTreeListDataColumn FieldName="EmployeeName" />
<DxTreeListDataColumn FieldName="StartDate" />
<DxTreeListDataColumn FieldName="DueDate" />
</Columns>
</DxTreeList>
@code {
List<EmployeeTask> TreeListData { get; set; }
protected override void OnInitialized() {
TreeListData = EmployeeTaskService.GenerateData();
}
void OnDataItemDeleting(TreeListDataItemDeletingEventArgs e) {
if (e.DataItem != null)
TreeListData.Remove((EmployeeTask)e.DataItem);
}
void CustomizeContextMenu(TreeListCustomizeContextMenuEventArgs args) {
if (args.Context is TreeListDataRowCommandContext rowContext) {
args.Items.AddCustomItem("Delete", () => {
args.TreeList.ShowRowDeleteConfirmation(rowContext.RowVisibleIndex);
});
}
}
}