StoreTree
Configs
3
Configs
3Other
When set to true, restores the expanded states of tree nodes when reloading data.
Tree
Set to true to fire a 'remove' event when moving a node (to mimic the behavior of versions < 6.0).
Set to true to on load transform a flat dataset with raw objects containing parentId into the format
expected for tree data.
Example input format:
[
{ id : 1, name : 'Parent' },
{ id : 2, name : 'Child', parentId : 1 }
]
Will be transformed into:
[
{
id : 1,
name : 'Parent',
children : [
{ id : 2, name : 'Child', parentId : 1 }
]
}
]
Properties
5
Properties
5Advanced
A special Symbol signalizing treeify method that the current record grouping should be stopped.
const newRoot = workerStore.treeify([
// group workers by company
worker => {
// if the worker is unemployed we don't put it in a group
// we just show such record on the root level
if (!worker.company) {
return Store.StopBranch
}
return worker.company;
}
]);
Class hierarchy
Tree
true if this Store is configured to handle tree data (with tree : true) or if this is a
chained store and the master store is a tree store.
Functions
5
Functions
5Returns the children of the passed branch node which this store owns. By default, this
is the entire children array.
If this store isChained, then this returns only the subset of children which are filtered into this store by the chainedFilterFn.
| Parameter | Type | Description |
|---|---|---|
parent | Model | The node to return the children of. |
Increase the indentation level of one or more nodes in the tree
| Parameter | Type | Description |
|---|---|---|
nodes | Model | Model[] | The nodes to indent. |
Loads children for a parent node that uses load on demand (when expanding it). Base implementation does nothing,
either use AjaxStore which implements it, create your own subclass with an implementation or listen for
toggleNode and insert records when you have them available.
| Parameter | Type | Description |
|---|---|---|
parentRecord | Model |
A Promise which will be resolved if the load succeeds, and rejected if the load is
vetoed by a beforeLoadChildren handler, or if an exception is detected.
The resolved function is passed the event object passed to any event handlers.
The rejected function is passed the exception event if an exception occurred,
or false if the load was vetoed by a beforeLoadChildren handler.
Decrease the indentation level of one or more nodes in the tree
| Parameter | Type | Description |
|---|---|---|
nodes | Model | Model[] | The nodes to outdent. |
Collapse an expanded record or expand a collapsed. Optionally forcing a certain state.
| Parameter | Type | Description |
|---|---|---|
idOrRecord | String | Number | Model | Record (the record itself) or id of a record to toggle |
collapse | Boolean | Force collapse (true) or expand (false) |
Events
4
Events
4Fired before nodes in the tree are indented. Return false from a listener to prevent the indent.
// Adding a listener using the "on" method
storeTree.on('beforeIndent', ({ source, records }) => {
});| Parameter | Type | Description |
|---|---|---|
source | Store | The |
records | Model[] | The nodes to indent. |
Fired before nodes in the tree are outdented. Return false from a listener to prevent the outdent.
// Adding a listener using the "on" method
storeTree.on('beforeOutdent', ({ source, records }) => {
});| Parameter | Type | Description |
|---|---|---|
source | Store | This store |
records | Model[] | Nodes to be outdented |
Event handlers
4
Event handlers
4Called before nodes in the tree are indented. Return false from a listener to prevent the indent.
new StoreTree({
onBeforeIndent({ source, records }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | Store | The |
records | Model[] | The nodes to indent. |
Called before nodes in the tree are outdented. Return false from a listener to prevent the outdent.
new StoreTree({
onBeforeOutdent({ source, records }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | Store | This store |
records | Model[] | Nodes to be outdented |