Skip to main content
All docs
V24.1

TreeListChildrenLoadingEventArgs.Children Property

Specifies data items that are children of the Parent node.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

public IEnumerable<object> Children { get; set; }

Property Value

Type Description
IEnumerable<Object>

A collection of child data items.

Remarks

Handle the ChildrenLoading or ChildrenLoadingOnDemand event to populate the TreeList component with hierarchical data in code. Use the Parent event argument to determine the processed node and assign the node’s children to the Children collection.

Read Tutorial: Bind Blazor TreeList to Data Run Demo: Load Data on Demand

The following example switches the TreeList component to on-demand mode:

@inject FileSystemDataProvider FileSystemDataProvider

<DxTreeList Data="TreeListData"
            HasChildrenFieldName="HasChildren"
            ChildrenLoadingOnDemand="TreeList_ChildrenLoadingOnDemand"
            CustomizeCellDisplayText="TreeList_CustomizeCellDisplayText">
    <Columns>
        <DxTreeListDataColumn FieldName="Name" />
        <DxTreeListDataColumn FieldName="Type" Width="100" />
        <DxTreeListDataColumn FieldName="DateModified" Width="120" />
        <DxTreeListDataColumn FieldName="Size" Width="100" />
    </Columns>
</DxTreeList>

@code {
    object TreeListData { get; set; }

    protected override async Task OnInitializedAsync() {
        TreeListData = await FileSystemDataProvider.GetRootItemsAsync();
    }

    Task TreeList_ChildrenLoadingOnDemand(TreeListChildrenLoadingOnDemandEventArgs e) {
        var item = e.Parent as FileSystemDataItem;
        e.Children = item.Children;
        return Task.CompletedTask;
    }

    void TreeList_CustomizeCellDisplayText(TreeListCustomizeCellDisplayTextEventArgs e) {
        if(e.FieldName == "Size") {
            var item = (FileSystemDataItem)e.DataItem;
            e.DisplayText = GetSizeColumnDisplayText(item.Type, item.Size);
        }
    }

    string GetSizeColumnDisplayText(FileType fileType, long size) {
        if(fileType == FileType.Folder)
            return null;
        if(size >= 1024)
            return string.Format("{0:### ### ###} KB", size / 1024);
        return string.Format("{0} Bytes", size);
    }
}

Load Blazor TreeList Data on Demand

See Also