Skip to main content
All docs
V25.1
  • DxTreeListDataColumn.ReadOnly Property

    Specifies whether a user can change the column editor value when the TreeList is in edit mode.

    Namespace: DevExpress.Blazor

    Assembly: DevExpress.Blazor.v25.1.dll

    NuGet Package: DevExpress.Blazor

    Declaration

    [DefaultValue(false)]
    [Parameter]
    public bool ReadOnly { get; set; }

    Property Value

    Type Default Description
    Boolean false

    true to prevent users from changing the editor value; false to allow users to change the editor value.

    Remarks

    The TreeList automatically generates editors for columns based on associated date types. Use an editor’s ReadOnly property to activate or deactivate the read-only mode for the editor displayed in edit form, pop-up edit form, or data rows during edit operations. If the editor property is unspecified, the column’s ReadOnly property defines whether the editor is in read-only mode.

    The ReadOnly property does not affect the editor displayed in the filter row. To hide the filter row editor, set the column’s FilterRowEditorVisible property to false.

    The following code snippet switches the editor in the ID column to the read-only mode:

    @inject EmployeeTaskService EmployeeTaskService
    
    <DxTreeList Data="TreeListData"
                KeyFieldName="Id"
                ParentKeyFieldName="ParentId"
                EditModelSaving="TreeList_EditModelSaving"
                DataItemDeleting="TreeList_DataItemDeleting"
                CustomizeEditModel="TreeList_CustomizeEditModel">
        <Columns>
            <DxTreeListCommandColumn />
            <DxTreeListDataColumn FieldName="Id" Caption="ID" ReadOnly="true"/>
            <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_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);
        }
    }
    

    Implements

    See Also