Avalonia.Controls.TreeDataGrid
Avalonia.Controls.TreeDataGrid copied to clipboard
[Feature] Way of filtering items without losing data in Items container
Right now you have to remove the items when initializing either HierarchicalTreeDataGridSource
or FlatTreeDataGridSource
resulting in loss of data when, for example, selecting an entry from the TreeDataGrid
.
My proposal is adding a Filter
property when initializing either HierarchicalTreeDataGridSource
or FlatTreeDataGridSource
to filter out any item instances when a specific predicate is met.
Example:
class Node
{
public string Name { get; set; }
public bool IsDirectory { get; set; }
public List<Node> Children { get; set; }
}
public HierarchicalTreeDataGridSource<Node> TreeDataGrid { get; set; }
...
public void PopulateDataGrid()
{
// Fill Node Container...
TreeDataGrid = new(<whatever_items>)
{
Columns =
{
new HierarchicalExpanderColumn<FileTreeNodeModel>(
new TextColumn<FileTreeNodeModel, string>("Name", node => nide.Name),
node => node.Cildren,
node => node.Children.Count > 0),
},
Filter = node => node.IsDirectory
};
}
This will only populate TreeDataGrid
with the items that have IsDirectory
set to true.
Are similar functions supported?