DxTreeList.GetColumnEditSettings<T>(String) Method
Returns editor settings of the column bound to the specified data source field.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v24.2.dll
NuGet Package: DevExpress.Blazor
Declaration
public T GetColumnEditSettings<T>(
string fieldName
)
where T : class, IEditSettings
Parameters
Name | Type | Description |
---|---|---|
fieldName | String | A data source field name. |
Type Parameters
Name | Description |
---|---|
T | An editor setting type. |
Returns
Type | Description |
---|---|
T | An object that contains editor settings. |
Remarks
The TreeList component generates and configures cell editors for columns based on associated data types. The component automatically displays column editors in the filter row and data rows during edit operations. You can also place these editors in the inline or pop-up edit form.
The TreeList allows you to access and customize editor settings at runtime. To get editor settings, pass a setting type and the corresponding data source field name to the GetColumnEditSettings
method. The method returns null
in the following cases:
- The TreeList does not have a column bound to the specified field.
- Editor settings of the column bound to the specified field are of a different type.
Note
Editors, their settings, and types can change after you bind the TreeList or its column to another data source. If the TreeList is bound to an asynchronous data source, editor types can change during TreeList initialization. If the TreeList is bound to server-mode data or loads data on demand, editor types can also change after the TreeList loads child nodes.
The following code snippet enables an editor in the edit row for new rows only:
@inject EmployeeTaskService EmployeeTaskService
<DxTreeList Data="TreeListData"
KeyFieldName="Id"
ParentKeyFieldName="ParentId"
EditModelSaving="TreeList_EditModelSaving"
DataItemDeleting="TreeList_DataItemDeleting"
CustomizeEditModel="TreeList_CustomizeEditModel"
EditStart="TreeList_EditStart">
<Columns>
<DxTreeListCommandColumn />
<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 TreeList_EditStart(TreeListEditStartEventArgs e) {
var settingsStartDate = e.TreeList.GetColumnEditSettings<IDateEditSettings>("StartDate");
if (settingsStartDate != null) {
e.TreeList.BeginUpdate();
settingsStartDate.Enabled = e.IsNew;
settingsStartDate.ShowDropDownButton = e.IsNew;
e.TreeList.EndUpdate();
}
}
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();
}
async Task TreeList_DataItemDeleting(TreeListDataItemDeletingEventArgs e) {
TreeListData.Remove((EmployeeTask)e.DataItem);
}
}
Handle the TreeList’s CustomizeFilterRowEditor event to customize editors in the filter row. The CustomizeDataRowEditor event allows you to customize editors displayed in data rows, inline, or pop-up edit forms.