Tree
Feature
Feature that makes the grid work more like a tree. Included by default in TreeGrid. Requires exactly one TreeColumn among grids columns. That column will have its renderer replaced with a tree renderer that adds padding and icon to give the appearance of a tree. The original renderer is preserved and also called.
targetElement.innerHTML = '<p>Tree feature requires a store with <code>{ tree: true }</code> and a TreeColumn among columns</p>'; const grid = new Grid({ appendTo : targetElement, height : 500, features : { tree : true }, store : { tree : true, data : [ { id : 1, name : 'ABBA', iconCls : 'fa fa-users', children : [ { id : 11, name : 'Anni-Frid', iconCls : 'fa fa-user' }, { id : 12, name : 'Bjorn', iconCls : 'fa fa-user' }, { id : 13, name : 'Benny', iconCls : 'fa fa-user' }, { id : 14, name : 'Agnetha', iconCls : 'fa fa-user' } ] }, { id : 2, name : 'Roxette', iconCls : 'fa fa-users', children : [ { id : 21, name : 'Per', iconCls : 'fa fa-user' }, { id : 22, name : 'Marie', iconCls : 'fa fa-user' } ] } ] }, columns : [ { type : 'tree', field : 'name', text : 'Name', flex : 1 } ] }); This feature is disabled by default. When enabled, the feature cannot be disabled during runtime.
Keyboard shortcuts
This feature has the following default keyboard shortcuts:
| Keys | Action | Action description |
|---|---|---|
| Space | toggleCollapseByKey | When focus on a parent node, this expands or collapses its children |
| ArrowRight | expandIfSingleColumn | Expands a focused parent node if grid consist of one column only |
| Shift+ArrowRight | expandByKey | Expands a focused parent node |
| ArrowLeft | collapseIfSingleColumn | Collapses a focused parent node if grid consist of one column only |
| Shift+ArrowLeft | collapseByKey | Collapses a focused parent node |
For more information on how to customize keyboard shortcuts, please see our guide
See also
- TreeGrid - The tree grid view
- TreeColumn - The tree column type
- TreeGroup - Group flat data into a tree
Configs
Configs are options you supply in a configuration object when creating an instance of this class-
Expand parent nodes when clicking on their cell
Has a corresponding runtime expandOnCellClick property.
-
keyMap : Object<String, KeyMapConfig>
See Keyboard shortcuts for details
-
Show or hide tree lines
Has a corresponding runtime treeLines property.
-
Internal listeners, that cannot be removed by the user.
-
The widget which this plugin is to attach to.
Has a corresponding runtime client property.
-
Set to
falseto disable localization of this object.
Properties
Properties are getters/setters or publicly accessible variables on this class-
Identifies an object as an instance of Events class, or subclass thereof.
-
Identifies an object as an instance of Localizable class, or subclass thereof.
-
Identifies an object as an instance of Tree class, or subclass thereof.
-
A class property getter for the default values of internal properties for this class.
-
Expand parent nodes when clicking on their cell
Has a corresponding expandOnCellClick config.
-
Show or hide tree lines
Has a corresponding treeLines config.
-
An empty array that can be used as a default value.
-
An empty object that can be used as a default value.
-
Identifies an object as an instance of InstancePlugin class, or subclass thereof.
-
Identifies an object as an instance of Tree class, or subclass thereof.
-
Returns a copy of the full configuration which was used to configure this object.
-
This property is set to
truebefore theconstructorreturns. -
This property is set to
trueon entry to the destroy method. It remains on the objects after returning fromdestroy(). If isDestroyed istrue, this property will also betrue, so there is no need to test for both (for example,comp.isDestroying || comp.isDestroyed). -
The Widget which was passed into the constructor, which is the Widget we are providing extra services for.
Has a corresponding client config.
-
Get the global LocaleHelper
-
Get the global LocaleManager
Functions
Functions are methods available for calling on the class-
This optional class method is called when a class is mixed in using the mixin() method.
-
Registers this class type with its Factory
-
onElementClick( )private
Called when user clicks somewhere in the grid. Expand/collapse node on icon click.
-
toggleCollapseByKey( )private
Called on key down in grid. Expand/collapse node on Space
-
Internal function used to hook destroy() calls when using thisObj
-
Internal function used restore hooked destroy() calls when using thisObj
-
Auto detaches listeners registered from start, if set as detachable
-
Internal function used to run a callback function after an event is triggered
-
Removes all listeners registered to this object by the application.
-
This will merge a feature's (subclass of InstancePlugin) keyMap with it's client's keyMap.
-
Collapse all nodes. This function is exposed on Grid and can thus be called as
grid.collapseAll() -
Expand all nodes. This function is exposed on Grid and can thus be called as
grid.expandAll()