vdl-treegrid
The VDL Tree grid component is a VDL Extension that provides an interface for users to visualize nested data in table format. The data must be structured in a certain way in order to build a table with nested data. To have child rows, it is necessary to provide an array of child data objects to the rows with the "_children" property. However, this property can be configured by using the children-field
attribute. Tree grid table requires data to be passed via the data attribute.
Add the compact
class to the parent vdl-page
to render the Tree Grid with compact style.
Example
<script>
const nestedData = [
{id:1, name:"Grandparent", prop1:"60",
"_children":[
{id:2, name:"Parent one", prop1:"45"}, //child rows nested under Grandparent
{id:3, name:"Parent two", prop1:"42"},
{id:4, name:"Parent three", prop1:"40",
"_children":[
{id:5, name:"Child one", prop1:"16"}, //child rows nested under Parent three
{id:6, name:"Child two", prop1:"12"},
]},
]},
{id:7, name:"Parent one", prop1:"45"},
{id:8, name:"Parent two", prop1:"42",
"_children":[
{id:9, name:"Child one", prop1:"10"}, //child row nested under Parent two
]},
{id:10, name:"Parent three", prop1:"40"}
]
</script>
<vdl-treegrid
column-definition="auto"
data="=nestedData">
</vdl-treegrid>
Attributes
always-show-selection | Whether to display selection on inactive grids. Set to true to keep selection on a grid when it becomes inactive. | since 5.2 | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
cell-render | A custom cell render function or expression that is applied to all cells in the datagrid. This affects the rendered output of the cell only, sorting and filtering are unaffected. The cell-render function should return either the original data unchanged, some new data to display in the cell or a new HTML element to insert into the cell. In addition to returning the original or modified cell data it can also modify the HTML cellElement that is passed in. If a cell-render function is provided on vdl-datagrid and a child vdl-datagrid-column has a render function, then the vdl-datagrid-column render function will take precedence.
|
since 5.3 | requires expression | ||||||||||||||||||||||||||||||||||
children-field | Default behavior of vdl-treegrid is to display nested data based on the _children property in the hierarchical source data, however this behavior may be overridden by passing different values to the property. |
since 5.2 | accepts expression | ||||||||||||||||||||||||||||||||||
class | Space-separated list of the classes of the element. | since 5.2 | |||||||||||||||||||||||||||||||||||
column-definition | Specify how columns are defined. This attribute can only be used in combination with the "data" attribute. Allowed values are: column-definition="auto" - Generates columns from the data (default)column-definition="labels" - Uses the "label" and "value" properties on an object. Data will be reduced to one row.column-definition="=[{ field: "name" }, { field: "age" }]" - An array of objects defining the column properties.When using column properties, you should supply a column definition object for each column you require and each object must have a property named 'field'. The value of the field property must reference a property on the data. Below is an example showing how columns, and even individual cells can be made editable. This also shows how dropdown options can be supplied with labels: Note: Any expandable cells (has children-field present) will not be editable.data =
Callback to determine if a cell is editable:
Callback to construct gender options:
column-definition =
Object passed to the cell-event handler: Handling the cell-edit event:
Callback to validate a cell:
Custom sorter:
Column definition objects accept the following configuration properties:
|
since 5.2 | accepts expression | ||||||||||||||||||||||||||||||||||
column-filter | Set this to true to enable the column filters. This will show a header row with filter inputs for each column. | since 5.2 | |||||||||||||||||||||||||||||||||||
data | Use this attribute to pass data directly to vdl-treegrid. Supported formats is; Array of objects: [{... prop: 1}] . |
since 5.2 | requires expression | ||||||||||||||||||||||||||||||||||
defer-column-filter | Set this to true to defer column filters from applying until the input loses focus. | since 5.3 | accepts expression | ||||||||||||||||||||||||||||||||||
freeze-columns | The number of columns to freeze in the table starting from the left hand column. Works best when vdl-treegrid is in a fixed width container. | since 5.2 | |||||||||||||||||||||||||||||||||||
header-tooltip-render | A custom render function or expression that is called for each column header in the treegrid and defines how to display the header's tooltip. It should return either a string or HTML content to display inside the tooltip, a DOM node to replace the tooltip or an undefined/nullish value to hide the tooltip.
|
since 5.7 | requires expression | ||||||||||||||||||||||||||||||||||
height | Grid height, When page-mode is set to scrolling you can set the height of the grid to something other than the default. | since 5.2 | |||||||||||||||||||||||||||||||||||
id | Specify an element id for the grid. Useful if you later want to target the grid using a selector. If not given then an id will be generated. | since 5.2 | |||||||||||||||||||||||||||||||||||
page-mode | By default the grid will show all rows in scrolling mode. Set this attribute to paged to enable grid pagination. | since 5.2 | |||||||||||||||||||||||||||||||||||
page-size | The number of rows to show per-page in paged mode. Defaults to 50. | since 5.2 | |||||||||||||||||||||||||||||||||||
save-state | Set this to false to disable grid state saving. By default grid state is stored in the user's browser session so that user settings (e.g. page, sorting and search) are preserved if grid data is reloaded. | since 5.2 | |||||||||||||||||||||||||||||||||||
start-expanded | By default all nodes on the tree will start collapsed, you can customize the initial expansion state of the tree using this attribute | since 5.2 | accepts expression | ||||||||||||||||||||||||||||||||||
tooltip-render | A custom render function or expression that is called for each cell in the treegrid and defines how to display the cell's tooltip.It should return either a string or HTML content to display inside the tooltip, a DOM node to replace the tooltip or an undefined/nullish value to hide the tooltip.The tooltip is not displayed on the bottom-calc row's cells.
|
since 5.3 | requires expression | ||||||||||||||||||||||||||||||||||
width | Set the grid to a fixed width, in pixels. Accepts an integer value. If set to the string custom then the grid width is calculated by adding up all the widths of the columns in the grid. If a column doesn't have a width specified then it is given a default value of 100px. | since 5.2 |
© 2001-2025 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.