Managing the tree column and expand/collapse icon
When rendering a tree, you have to use the
<TreeGrid /> component instead of <InfiniteTable />.The
<TreeGrid /> component is simply an <InfiniteTable /> component with some props removed - those don't make sense for tree scenarios.By default no tree column is rendered.
To specify the tree column, you have to to set the
columns.renderTreeIcon prop to true for your column of choice.const columns: Record<string, InfiniteTableColumn<FileSystemNode>> = {
name: {
renderTreeIcon: true,
field: 'name',
header: 'Name'
},
type: { field: 'type', header: 'Type' },
size: { field: 'sizeInKB', type: 'number', header: 'Size (KB)' },
};This is very similar to how you specify the selection column for multi-select configurations.
#
Specifying the tree column
loading demo…
Customizing the expand/collapse icon#
Using the
column.renderTreeIcon=true is obviously not enough to customize the expand/collapse icon.This prop can also be a function that returns a VNode, created with
h().With the default value of
true for columns.renderTreeIcon, an icon will be rendered only for parent nodes.If you want to render an icon for all nodes, specify a function (and differentiate between parent and leaf nodes), and it will be called regardless of whether the node is a parent or a leaf.
#
Customizing the expand/collapse icon
loading demo…