-
Notifications
You must be signed in to change notification settings - Fork 188
Description
` updateCampaignScriptTreeModel(script: IScript): void {
let targetScriptNodeController: TreeController = this.scriptTreeComponent.getControllerByNodeId(script.id);
if (targetScriptNodeController) {
let targetScriptTreeModel = targetScriptNodeController.toTreeModel();
if (targetScriptTreeModel.title !== script.title) {
targetScriptNodeController.rename(script.title);
}
}
else {
let targetParentScriptNodeController: TreeController = this.scriptTreeComponent.getControllerByNodeId(script.parentScriptId);
if (!targetParentScriptNodeController) {
targetParentScriptNodeController = this.scriptTreeComponent.rootComponent.controller;
}
targetParentScriptNodeController.addChild({ id: script.id, value: script.title, children: [] });
targetParentScriptNodeController.expand();
let addedScriptModelController: TreeController = this.scriptTreeComponent.getControllerByNodeId(script.id);
addedScriptModelController.select();
}
}`
I'm dynamically updating a TreeModel based on an arbitrary data model object ("script" in the example above). When using "addChild" in the above, I note that the children are added to the correct parent TreeModel as expected and the added nodes appear correctly in my tree.
However, it seems no new TreeController is added to the TreeService.controllers collection as part of the addChild function (I have verified this in a debugger). Consequently, the subsequent call to get the "addedScriptModelController" returns a null. Per the code my intent in this case is to "select" the newly created node after it is added. Obviously, relying on the rest of the API also requires access to an existing node controller for newly "added" nodes.
Am I doing something wrong here, or are there design limitations that prevent controllers from being added as part of of the addChild function?