0

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.

CipherDarkness
  • 214
  • 1
  • 8
  • 18
  • Could you detail what do you mean by problems with initialization and items? – OnaBai Nov 21 '12 at 22:59
  • This initialization happens on [this](http://jsfiddle.net/OnaBai/UC3uW/) fiddle you posted the other day too!Try just pressing "show" and you'll see the `"items":"[]"` attribute added by kendo.I believe this is the reason why `dataItem().append()` doesn't work on those nodes and if I can dynamically delete the `"items"` field maybe I can use this `.append()` on all nodes and finally fix this problem – CipherDarkness Nov 22 '12 at 08:38
  • Deleting an object field is `delete XXX`. I`ve updated the [fiddle] (http://jsfiddle.net/OnaBai/UC3uW/1/) by adding a third option called `remove` 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. – OnaBai Nov 22 '12 at 09:50
  • The method works,post it as an answer so I can mark it right. Though it doesn't solve the problem indeed.. :/ – CipherDarkness Nov 22 '12 at 11:23

2 Answers2

1

I've just discovered something interesting about Kendo's suggested answer at: http://www.telerik.com/forums/clear-all-nodes

Using their code suggestion, will also delete the .items attribute:

$(".k-treeview").data("kendoTreeView").remove(".k-item");
Clomp
  • 3,168
  • 2
  • 23
  • 36
0

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.

OnaBai
  • 40,767
  • 6
  • 96
  • 125