Mark
Mark

Reputation: 4970

Angular Kendo treeview - update node text

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

Upvotes: 0

Views: 99

Answers (1)

Mark
Mark

Reputation: 4970

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.

Upvotes: 0

Related Questions