DxTreeList.IsEditing() Method
Returns whether the TreeList is being edited.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v24.2.dll
NuGet Package: DevExpress.Blazor
Declaration
public bool IsEditing()
Returns
Type | Description |
---|---|
Boolean |
|
Remarks
Call the IsEditing
method to check whether the TreeList is in edit mode. The IsEditingRow(Int32) 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.
@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