Skip to content
FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    Display tabular and hierarchical data

    Use TreeDataGrid when records need columns, sorting, cell editing, or expandable child rows. For a simple selectable list, start with ListBox instead.

    Add ferroui-controls-treedatagrid and the data-model crate ferroui-treedatagrid-core at the same version as your framework. Register the control types and load the matching theme resources; the complete demo shows that setup.

    Terminal window
    cargo run -p treedatagrid-demo

    Open the Countries page to try sorting and filtering, then People to try declarative columns and hierarchy. The demo source includes the data models, theme setup, and view registration.

    In XAML, this fragment expects a registered People collection on the view model and registered Name and Title properties on each item. It uses runtime bindings to keep the example independent of an application’s namespace:

    This fragment uses explicit reflection bindings because it omits your application’s registered source types. See compiled binding setup for typed XAML.

    <TreeDataGrid xmlns="https://github.com/ferroui"
    ItemsSource="{ReflectionBinding People}" SelectionMode="Row,Multiple">
    <TreeDataGridTextColumn Header="Name" Width="2*" Binding="{ReflectionBinding Name}" />
    <TreeDataGridTextColumn Header="Title" Width="2*" Binding="{ReflectionBinding Title}" />
    </TreeDataGrid>

    ItemsSource supplies records; column bindings read each record. The People XAML example adds compiled bindings, a child expander, a template column, and check boxes.

    With the treedatagrid feature of ferroui-view, the grid and its cells and rows have builders like every other control. A component keeps the source in a hook and gives it to the grid’s source property; the ViewGallery sample builds a FlatTreeDataGridSource with three text columns this way:

    let source = use_hook(languages); // a function returning a TreeDataGridSourceRef
    rsx! { TreeDataGrid { source: source } }

    See the ViewGallery source for the source and its columns (cargo run -p view-gallery).

    Need Starting point
    Flat records with programmatic columns FlatTreeDataGridSource
    Records with expandable children HierarchicalTreeDataGridSource
    Columns declared alongside the view ItemsSource and XAML column declarations
    Framework-neutral column models Core source assigned through the control’s Model path

    For programmatic columns, accessors describe how to read and optionally write item properties. Use the public Countries view model as an end-to-end example of a notifying list, text columns, a template column, filtering, and row selection.

    Keep record identity stable. Notify item property changes when a cell value changes, and notify collection changes when adding or removing records. A plain vector mutation does not tell the grid what changed.

    Choose whether the task selects rows or cells. When deleting or filtering a selected record, update the application’s selection deliberately. For hierarchy, decide where expansion state lives so a refresh does not unexpectedly close every node.

    Place the grid in a * row of a constrained Grid. Avoid wrapping it in another scrolling container. Test with enough rows and columns to require scrolling, and verify keyboard editing, empty data, and theme changes.