This is a migrated thread and some comments may be shown as answers.

Reorder items of MVVM Hierarchical DS treeview

2 Answers 80 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
P
Top achievements
Rank 1
P asked on 05 Nov 2013, 08:42 AM
Hello,

I am creating tree using MVVM. I get data from server in flat json object and make necessary tree json structure on client side.  Don't know if that cause the problem, but  reordering of tree items does not work, I get following errors:

Uncaught TypeError: Cannot read property 'nextSibling' of undefined kendo.all.min.js:25
Uncaught TypeError: Cannot read property 'uid' of undefined

... and others. I tried to debug but was not able to find the problem. Any help on fixing errors or advices how to better define data source for the mvvm tree would be much appreciated.

You can find all code here:

http://jsfiddle.net/5fqph/10/



2 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 07 Nov 2013, 08:29 AM
Hi,

I checked the jsFiddle that you provided and found the following issues:

  1. The jQuery version should be changed to 1.9.1.
  2. The data is read twice. Since the autoBind option is not used to prevent the initial binding, the TreeView will call the read method automatically. 
  3. A plain JavaScript array should be returned from the read action and not a ObservableHierarchy. In order to bind correctly the children you should set the model children field instead. The ObservableHierarchy should be used only to bind hierarchical data directly to the TreeView without creating a HierarchicalDataSource.

Also, there is a known issue in the official release when the HierarchicalDataSource is set to an ObservableObject that is already fixed in the latest internal builds. An error is thrown when adding/dropping items to the root level since the dataSource parent will be the ObservableObject. In order to avoid the error with the current version, I can suggest either to move the dataSource out of the viewModel or override the dataSource parent. 
I updated the jsFiddle with the needed changes.

Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
P
Top achievements
Rank 1
answered on 08 Nov 2013, 11:26 AM
Thank you for your answer. I applied your changes but it didn't work until I updated my Kendo version with the same as in jsfiddle. Then it start working.

Thanks again for great help.
Tags
TreeView
Asked by
P
Top achievements
Rank 1
Answers by
Daniel
Telerik team
P
Top achievements
Rank 1
Share this question
or