I want to update the selected node text with a value from a text box. for this I have a reactive form. I am subscribing to element's changes and updating node's text. Here is my code:
get formControls() {
return this.formEditor.controls;
}
this.formControls.assetGroupNameControl.valueChanges.subscribe(value => {
let selectedNode = this.treeview.itemLookup(this.currentTreeIndex);
selectedNode.item.dataItem.text = value;
this.cd.detectChanges();
I will need to change the tree selection to see the change. Any reason why the change is not taking effect right away?
Thanks
In order to see the update right away the focus has to be returned back to the tree. The tree has selectedKeys array. So, if a node with index "0_1" is under modification here is the code to execute:
selectedKeys.push("0_1");
selectedKeys = [...selectedKeys];
Second line is needed because the tree only reacts on a change when array's reference has been changed.