StoreTree

Configs

3

Other

keepExpandedOnLoad: Boolean= false

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

Advanced

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

isStoreTree: Boolean= truereadonly
Identifies an object as an instance of StoreTree class, or subclass thereof.
isStoreTree: Boolean= truereadonlystatic
Identifies an object as an instance of StoreTree class, or subclass thereof.

Tree

isTree: Booleanreadonly

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.

Returns all leaf records in a tree store

Functions

5

Returns 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.

ParameterTypeDescription
parentModel

The node to return the children of.

Returns: Model[]

Increase the indentation level of one or more nodes in the tree

ParameterTypeDescription
nodesModel | 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.

ParameterTypeDescription
parentRecordModel
Returns: Promise -

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

ParameterTypeDescription
nodesModel | Model[]

The nodes to outdent.

Collapse an expanded record or expand a collapsed. Optionally forcing a certain state.

ParameterTypeDescription
idOrRecordString | Number | Model

Record (the record itself) or id of a record to toggle

collapseBoolean

Force collapse (true) or expand (false)

Events

4

Fired 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 }) => {

});
ParameterTypeDescription
sourceStore

The

recordsModel[]

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 }) => {

});
ParameterTypeDescription
sourceStore

This store

recordsModel[]

Nodes to be outdented

Fired after tasks in the tree are indented

// Adding a listener using the "on" method
storeTree.on('indent', ({ source, records }) => {

});
ParameterTypeDescription
sourceStore

The store

recordsModel[]

Nodes that were indented

Fired after tasks in the tree are outdented

// Adding a listener using the "on" method
storeTree.on('outdent', ({ source, records }) => {

});
ParameterTypeDescription
sourceStore

The store

recordsModel[]

Nodes that were outdented

Event handlers

4

Called before nodes in the tree are indented. Return false from a listener to prevent the indent.

new StoreTree({
    onBeforeIndent({ source, records }) {

    }
});
ParameterTypeDescription
sourceStore

The

recordsModel[]

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 }) {

    }
});
ParameterTypeDescription
sourceStore

This store

recordsModel[]

Nodes to be outdented

Called after tasks in the tree are indented

new StoreTree({
    onIndent({ source, records }) {

    }
});
ParameterTypeDescription
sourceStore

The store

recordsModel[]

Nodes that were indented

Called after tasks in the tree are outdented

new StoreTree({
    onOutdent({ source, records }) {

    }
});
ParameterTypeDescription
sourceStore

The store

recordsModel[]

Nodes that were outdented