TreeDataGrid column types
TreeDataGrid currently supports three different column types:
TextColumnis useful when you want all cells in the column to have only text values. Usually, everything you need to instantiate
new TextColumn<Person, string>("First Name", x => x.FirstName)
The first generic parameter here is your model type basically, the place where you want to grab data from. Person in this case. The second generic parameter here is the type of the property where you want to grab data from. In this case, it is a string, it will be used to know exactly which type your property has.
This is the signature of the
TextColumnconstructor. There are two most important parameters. The first one will be used to define the column header, usually, it would be a string. In the sample above it is "First Name". The second parameter is an expression to get the value of the property. In the sample above it is x => x.FirstName.
Note: The sample above is taken from this article. If you feel like you need more examples feel free to check it, there is a sample that shows how to use TextColumns and how to run a whole
HierarchicalExpanderColumncan be used only with
HierarchicalTreeDataGrid(a.k.a TreeView) that's what Hierarchical stands for in its name, also it can be used only with
HierarchicalTreeDataGridSource. This type of columns can be useful when you want cells to show an expander to reveal nested data.
That's how you instantiate
new HierarchicalExpanderColumn<Person>(new TextColumn<Person, string>("First Name", x => x.FirstName), x => x.Children)
HierarchicalExpanderColumnhas only one generic parameter, it is your model type, same as in
TextColumn, Person in this case.
Let's take a look at the
The first parameter in the constructor is a nested column, you would usually want to display something besides the expander and that's why you need this parameter. In the sample above, we want to display text and we use
TextColumnfor that. The second parameter is a selector of the child elements, stuff that will be displayed when
Expanderis in the expanded state below the parent element.
Note: The sample above is taken from this article. If you feel like you need more examples feel free to check it, there is a sample that shows how to use
HierarchicalExpanderColumnand how to run a whole
TemplateColumn is the most customizable option to create a column. You can put basically everything that you can put into
IDataTemplateinto this column cells.
That's how you instantiate
new FuncDataTemplate<FileTreeNodeModel>((a,e) => new CheckBox()))
TemplateColumnhas only one generic parameter, it is your model type, same as in
TextColumn, Person in this case. Code above will create a column with header "Selected" and
CheckBoxin each cell.
TemplateColumnhas only two required parameters. The first one is the column header as everywhere. The second is
IDataTemplatebasically, a template that contains stuff that you want to be displayed in the cells of this column.