kor TürkçeGitHub

TreeGrid

Adds expandable branches to the DataGrid.

kor/ui/TreeGridSource

When to use

  • Show detail rows within a hierarchy such as cost centers and budget lines.

Examples

Bind nested data

Loading the example

<k:TreeGrid id="tree" label="Cost centers" height="13rem" rows="{path:'/nodes', parameters:{arrayNames:['children']}}" openLevels="0">
	<k:columns>
		<k:Column label="Cost center" path="name" grow="1"/>
		<k:Column label="Budget" path="budget" type="number"/>
	</k:columns>
</k:TreeGrid>

Control expansion depth

Loading the example

<k:Stack gap="8">
	<k:Button text="Expand cost centers" press=".onExpand"/>
	<k:TreeGrid id="tree" label="Cost centers" height="13rem" rows="{path:'/nodes', parameters:{arrayNames:['children']}}" toggle=".onToggle" openLevels="0">
		<k:columns>
			<k:Column label="Cost center" path="name" grow="1"/>
			<k:Column label="Budget" path="budget" type="number"/>
		</k:columns>
	</k:TreeGrid>
</k:Stack>

Keyboard

← →
Collapse or expand the focused branch.

API

Also has everything from DataGrid

Properties

NameTypeDefaultDescription
openLevelsint1Number of levels initially expanded

Events

NameTypeDescription
togglecontext: object
open: boolean
A branch opened or closed and may load children

Methods

NameDescription
toggle(row: number, to?: boolean): voidOpens or closes a branch at a visible row index
expandToLevel(level: number): voidExpands branches to the given level. Zero closes all branches
getState(): objectReturns column state and the paths of open branches
setState(state: Parameters<DataGrid["setState"]>[0] & { open?: string[] }): voidRestores column state and open branches

Related

DataGridVariants