Reputation: 420
I'll keep the question below, but if anybody else has this problem the issue was a bug in kendo and has been fixed in the most recent version. So the solution is to update to the latest kendo release.
I've been trying to find a good way of listing all of the nodes in a kendo-ui treeview, and have managed to put together a pretty solid way of doing so. First I define the dataSource, for the sake of simplicity let's say:
data = [
{text:element1, items:[
{text:element2},
{text:element3}]},
{text:element4}]
Then, I set the data source as an observableHierarchy:
my_treeview.setDataSource(kendo.observableHierarchy(data));
When I want to access the list of nodes, I can get a JSON object with:
my_treeview.dataSource.data().toJSON();
This works well; it produces a correct, properly-formatted JSON object. If I call JSON.stringify on the above, I get:
[{"text":"element1","items":[{"text":"element2","items":[]},{"text":"element3","items":[]}]},{"text":"element4","items":[]}]
However, when I enable drag and drop on my tree and drag an element into a different parent, it disappears from the json output. For example, if I drag element3 into element4, the json object returned is:
[{"text":"element1","items":[{"text":"element2","items":[]}]},{"text":"element4","items":[]}]
Which is the equivalent of:
data = [
{text:element1, items:[
{text:element2}]}
{text:element4}]
The table's display remains correct, however, with element 3 appearing to be a child of element4. So my question is, how can I get the dataSource to update properly with drag & drop?
Upvotes: 0
Views: 1691
Reputation: 420
If anybody else has this problem, the issue was a bug in kendo which has been fixed in the most recent version. So the solution is to update to the latest kendo release.
Upvotes: 2