Skip to main content
All docs
V26.1
  • DxTreeViewDataMappingBase.Selected Property

    Maps a data source field that specifies whether a TreeView node is selected.

    Namespace: DevExpress.Blazor.Base

    Assembly: DevExpress.Blazor.v26.1.dll

    Declaration

    [DefaultValue(null)]
    [Parameter]
    public string Selected { get; set; }

    Property Value

    Type Default Description
    String null

    The field name.

    Remarks

    The Selected property maps a Boolean field from your data source to the selected state of TreeView nodes. When the mapped field value is true, the corresponding node is selected.

    Note

    To allow selection, set the AllowSelectNodes property to true.

    The following code snippet maps the IsSelected field to the initial selected state of a TreeView node:

    <DxTreeView Data="@Departments"
                AllowSelectNodes="true">
        <DataMappings>
            <DxTreeViewDataMapping Children="Children"
                                   Text="Name"
                                   Selected="IsSelected" />
        </DataMappings>
    </DxTreeView>
    
    @code {
        List<Department> Departments = new List<Department> {
            new Department {
                Name = "Engineering",
                Children = new List<Department> {
                    new Department { Name = "Frontend" },
                    new Department { Name = "Backend" }
                }
            },
            new Department {
                Name = "Marketing",
                IsSelected = true
            }
        };
    }
    

    When a user selects an item, the component does not update the mapped field in your data source. Handle the SelectionChanged event to update the data source programmatically.

    See Also