Goran303
Goran303

Reputation: 601

kendo treeView change node text

Is it possible to dinamically change text in the kendo treeView?

var dataSource = treeView.dataSource;
var dataItem = dataSource.get(parseInt($('#inputIdOrgJed' + '@guid').val(), 10));
var node = treeView.findByUid(dataItem.uid);
treeView.select(node);
treeView.text(node, "ChangedText");

On ajax Update a node text should directly change. read action closes the tree so I cant use it, unless there is a way to avoid this.

Upvotes: 2

Views: 4670

Answers (2)

sosha
sosha

Reputation: 217

 var selectedNode = treeview.select();
 var item = treeview.dataItem(selectedNode);  
 item.set("text", "Changed Text");

the point is the first parameter of item.set("text" that should be the dataTextField defined inkendoTreeView configuration.

Upvotes: 1

Richard
Richard

Reputation: 27526

dataItem() is an observable array, so using .set() should cause the renderers to update the display automatically.

Presuming the data item text field is named 'text'.

treeview.dataItem(node).set('text', "New node text");

Upvotes: 1

Related Questions