Skip to main content
All docs
V25.1
  • DxTreeList.IsEditingRow(Int32) Method

    Returns whether the specified TreeList row is being edited.

    Namespace: DevExpress.Blazor

    Assembly: DevExpress.Blazor.v25.1.dll

    NuGet Package: DevExpress.Blazor

    Declaration

    public bool IsEditingRow(
        int visibleIndex
    )

    Parameters

    Name Type Description
    visibleIndex Int32

    The row’s visible index.

    Returns

    Type Description
    Boolean

    true if the specified row is being edited; otherwise, false.

    Remarks

    Call the IsEditing() method to check whether the TreeList is in edit mode. The IsEditingRow method allows you to identify whether the specified row is being edited. The IsEditingNewRow() method returns whether a new or existing row is in edit mode.

    Note

    When the TreeList is bound to the GridDevExtremeDataSource or loads data on demand, call the WaitForRemoteSourceRowLoadAsync(Int32) method before you execute the IsEditingRow method to ensure that the specified data row is loaded.

    @inject EmployeeTaskService EmployeeTaskService
    
    <DxTreeList @ref="MyTreeList"
                Data="TreeListData"
                KeyFieldName="Id"
                ParentKeyFieldName="ParentId"
                EditModelSaving="TreeList_EditModelSaving"
                CustomizeEditModel="TreeList_CustomizeEditModel">
        <Columns>
            <DxTreeListCommandColumn DeleteButtonVisible="false" />
            <DxTreeListDataColumn FieldName="Name" Caption="Task" />
            <DxTreeListDataColumn FieldName="EmployeeName" />
            <DxTreeListDataColumn FieldName="StartDate" />
            <DxTreeListDataColumn FieldName="DueDate" />
        </Columns>
    </DxTreeList>
    
    <br />
    <DxButton Click="() => IsEditingInfo = MyTreeList.IsEditing()" Text="Is Editing" />
    <DxButton Click="() => IsEditingFirstRowEInfo = MyTreeList.IsEditingRow(0)" Text="Is Editing First Row" />
    <DxButton Click="() => IsEditingNewRowInfo = MyTreeList.IsEditingNewRow()" Text="Is Editing New Row" />
    
    <div><b>Is Editing</b>: @IsEditingInfo</div>
    <div><b>Is Editing First Row</b>: @IsEditingFirstRowEInfo</div>
    <div><b>Is Editing New Row</b>: @IsEditingNewRowInfo</div>
    
    @code {
        List<EmployeeTask> TreeListData { get; set; }
        ITreeList MyTreeList { get; set; }
        bool IsEditingInfo { get; set; }
        bool IsEditingFirstRowEInfo { get; set; }
        bool IsEditingNewRowInfo { get; set; }
    
        protected override void OnInitialized() {
            TreeListData = EmployeeTaskService.GenerateData();
        }
        void TreeList_CustomizeEditModel(TreeListCustomizeEditModelEventArgs e) {
            if (e.IsNew) {
                var newTask = (EmployeeTask)e.EditModel;
                newTask.Id = TreeListData.Max(x => x.Id) + 1;
                if (e.ParentDataItem != null)
                    newTask.ParentId = ((EmployeeTask)e.ParentDataItem).Id;
            }
        }
        async Task TreeList_EditModelSaving(TreeListEditModelSavingEventArgs e) {
            if (e.IsNew)
                TreeListData.Add((EmployeeTask)e.EditModel);
            else
                e.CopyChangesToDataItem();
        }
    }
    

    Refer to the following topic for more information: Editing and Validation in Blazor TreeList.

    See Also