Releases: cheton/infinite-tree
Releases · cheton/infinite-tree
v1.12.5
v1.12.4
Adds an optional complete callback to the next
function of the loadNodes option (62b11af)
loadNodes: (parentNode, next) => { // Load node on demand
// Loading...
const nodes = [];
nodes.length = 1000;
for (let i = 0; i < nodes.length; ++i) {
nodes[i] = {
id: `${parentNode.id}.${i}`,
name: `${parentNode.name}.${i}`,
loadOnDemand: true
};
}
next(null, nodes, function() {
// Complete callback
});
}
v1.12.3
v1.12.2
v1.12.1
Defines the behavior for:
tree.filter(predicate, options)
Invalid predicate
Only a string or a function is accepted for the predicate parameter. For example, tree.filter()
, tree.filter(null)
, tree.filter(0)
, or tree.filter({})
will render nothing.
Empty string
Calling tree.filter('')
will filter all nodes in the tree.
v1.12.0
Improvements
- Support for filtering (closes #3)
How to filter nodes?
In your row renderer, returns undefined or an empty string to filter out unwanted nodes (i.e. node.state.filtered === false
):
import tag from 'html5-tag';
const renderer = (node, treeOptions) => {
if (node.state.filtered === false) {
return;
}
// Do something
return tag('div', treeNodeAttributes, treeNode);
};
The filter function accepts a keyword string, or a function to test each node of the tree. The function returns true to keep the node, false otherwise.
Filter by string
const keyword = 'text-to-filter';
const filterOptions = {
caseSensitive: false,
exactMatch: false,
filterPath: 'props.name', // Defaults to 'name'
includeAncestors: true,
includeDescendants: true
};
tree.filter(keyword, filterOptions);
Filter by function
const keyword = 'text-to-filter';
const filterOptions = {
includeAncestors: true,
includeDescendants: true
};
tree.filter(function(node) {
const name = node.name || '';
return name.toLowerCase().indexOf(keyword) >= 0;
});
Turn off filter
Calls tree.unfilter()
to turn off filter.
tree.unfilter();
v1.11.0
Events
- Added willCloseNode event (8ec6e91)
- Added willOpenNode event (8ec6e91)
- Added willSelectNode event (8ec6e91)
Examples
- Provides a multiple selection example using ctrl key or meta key (d98bc5d)
v1.10.0
v1.9.0
Functions: Tree
moveNodeTo(node, parentNode, index)
swapNodes(node1, node2)