Redux / Immutable Data
Use ID
Working with the tree using immutable data is possible.
Make sure that:
- You provide a unique
id
property on each node - If you have a different key property, then set the
idField
in the options - You override drop action as stated below
Override drop action
Drag and drop by default mutates the children.
If working with immutable data, you must override the action and supply your custom behaviour:
options = {
actionMapping: {
mouse: {
drop: (tree: TreeModel, node: TreeNode, $event: any, {from , to}: {from: any, to: any}) => {
// custom action. parameters: from = node, to = {parent, index}
}
}
}
}
Rebuilding the tree
Every time the nodes array changes, the entire tree model is rebuilt.
This might be costly if you have a huge amount of nodes that change very frequently.
Updated less than a minute ago