TreeColumn
A column that displays a tree structure when using the Tree feature.
Default editor is a TextField.
TreeColumn provides configs to define icons for expanded / collapsed nodes, expanded folder / collapsed folder nodes and leaf nodes.
When the TreeColumn renders its cells, it will look for two special fields href and target. Specifying href will produce a link for the TreeNode, and target will have the same meaning as in an A tag:
{
id : 1,
name : 'Some external link'
href : '//www.website.com",
target : '_blank"
}
Snippet
new TreeGrid({
appendTo : document.body,
columns : [
{ type: 'tree', field: 'name' }
]
});
Cell renderers
You can affect the contents and styling of cells in this column using a renderer function.
const grid = new Grid({
columns : [{
type : 'tree',
field : 'name',
text : 'Name',
renderer({ value, record }) {
return `${value} (${record.childLevel})`
}
}]
});
Alternative: tree: true config
Instead of using type: 'tree', you can add tree rendering to any column type by configuring it with tree: true:
const grid = new TreeGrid({
columns : [
// These are equivalent:
{ type: 'tree', field: 'name' },
{ field: 'name', tree: true },
// Any column type can be a tree column:
{ type: 'resourceInfo', tree: true, field: 'name' },
{ type: 'check', tree: true, field: 'done' }
]
});
Useful configs
| Config | Description |
|---|---|
| expandIconCls | Icon for expanded nodes |
| collapseIconCls | Icon for collapsed nodes |
| leafIconCls | Icon for leaf nodes |
| expandedFolderIconCls | Icon for expanded folder nodes |
| collapsedFolderIconCls | Icon for collapsed folder nodes |
See also
No results
Configs
Configs are options you supply in a configuration object when creating an instance of this classProperties
Properties are getters/setters or publicly accessible variables on this class-
Identifies an object as an instance of TreeColumn class, or subclass thereof.
-
Identifies an object as an instance of TreeColumn class, or subclass thereof.
CSS variables
CSS variables that can be set to adjust appearance| Name | Description |
|---|---|
| --b-tree-cell-gap | Gap between the internals of a tree cell |
| --b-tree-expander-color | Color of the expander icon |
| --b-tree-expander-icon-font-size | Size of the expander icon (font icon) |
| --b-tree-icon-color | Color of a tree icon |
| --b-tree-icon-width | Width of the tree icon |
| --b-tree-indent-size | Amount to indent each level of the tree |
| --b-tree-leaf-icon-font-size | Size of the leaf icon (font icon) |
| --b-tree-line-color | Color of a tree line |
| --b-tree-line-offset | Offset of the tree line (adjust to align with the apps collapse/expand icon) |
| --b-tree-line-width | Width of a tree line |
| --b-tree-loading-icon | Icon to display when loading children (font icon) |
| --b-tree-parent-color | Parent row's color |
| --b-tree-parent-font-weight | Parent row's font-weight |
type: tree