Search code examples
attributestreeviewkendo-uidataitem

Kendo UI Delete a node attribute in Treeview


I have some nodes who contain the items value which seems to be initialized by default from Kendo with the value "[]" everytime!

I want to completely delete the "items" field from the node but I can't seem to find any method for attribute deleting.

I try to access the nodes through dataItem and I tried dataItem.set("items",undefined) but still I don't think it helped.I'm trying to delete the items field because there seems to be a problem with that initialization done by kendo and I can't append new nodes to them and I think it's because of it...

EDIT :

It seems that kendo.observableHierarchy(data) initializes every tree node with no children (and therefore without an items attribute all).And by initializing I mean that everytime I show the dataSource the nodes that have no children have the "items":[] attribute added to them automatically!

I tried appending nodes through treeview.dataItem(treeview.select()).append() but I found out that this method doesn't work on "old" nodes that have the "items":[] attribute added to them by kendo,so "old" nodes are all the nodes that have been loaded on the tree from page load and therefore were saved on the JSON file.

And I say "old" because if I append a new node it doesn't have the "items" field and the .append() mentioned above works pretty fine on it adding a node and updating the dataSource..This .append() works pretty fine also on "old" nodes that already have children and so their "items" field is not modified by kendo because it already exists.


Solution

  • Deleting an object field is delete XXX. Ive updated the [fiddle] (jsfiddle.net/OnaBai/UC3uW/1) by adding a third option calledremove` but unless I misunderstood what you were suggesting, it does not solve the problem. I'm afraid that this is a feature in KendoUI that does not manage HierarchicalDataSources as we expect.