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

TypeError thrown when trying to do drag and drop on treeview

5 Answers 166 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Jeremy
Top achievements
Rank 1
Jeremy asked on 24 Jul 2013, 11:17 PM
I am getting the following error when I enable drag and drop on the treeview:

Uncaught TypeError: Cannot read property 'nextSibling' of undefined

This happens when I try and drag an item in the tree.

I am using Google Chrome but have also observed the same behavior in Firefox.

Here's the code I'm using to create the treeview:

this.dataSource = new kendo.data.HierarchicalDataSource({
            schema: {
                model: { id : "id", hasChildren: true,  children: "layers" }
            }
        });
 
        // treeview for navigation]
        this._treeViewSelector = uiElement;
        $(uiElement).kendoTreeView({
            dragAndDrop: true,
            checkboxes: {
                checkChildren: true
            },
            dataSource: this.dataSource
        });
And then to add data to the model I am using:

this.dataSource.add({id: id, text: name, expanded: true, checked: true, children: []});

Thanks for the help!

5 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 26 Jul 2013, 03:34 PM
Hello Jeremy,

I tried to reproduce this in jsBin with the latest scripts, but everything appeared to be working. Can you please adjust the sample so it matches your scenario? 

Regards,
Alex Gyoshev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Jeremy
Top achievements
Rank 1
answered on 26 Jul 2013, 10:48 PM
It appears to only occur when the model object added contains the option "expanded: true"

Here's a short example: jsBin

UPDATE: This also appears to happen when the option "expanded: true" is not set but the user clicks on the arrow to expand when the item has no children to show.  The arrow dissappears when the user clicks on it and then the next time that they try and do drag and drop with that particular item in the tree view the above error gets thrown.
0
Alex Gyoshev
Telerik team
answered on 29 Jul 2013, 09:16 AM
Hello Jeremy,

We have resolved this error for the next internal build, which should be released this week. You may consider specifying these fields only where they make sense (i.e. an item without items cannot be expanded, since it doesn't have items); having expand arrows on items without children is usually confusing for users, as clicking the arrows does not do anything.

Regards,
Alex Gyoshev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Jeremy
Top achievements
Rank 1
answered on 29 Jul 2013, 05:51 PM
Great!  I agree about the expand arrows ... that's  why I was passing expanded:true, because it made the arrows disappear.
0
Alex Gyoshev
Telerik team
answered on 30 Jul 2013, 08:02 AM
The hasChildren field controls this -- if it is set, the arrow shows up. In the jsBin, because the model is defined with hasChildren: true, all items default to having children, and thus, their arrows show. If you specify that field for each node (instead of expanded: true), you may get better results (since you'll serialize the actual data)
 
Regards,
Alex Gyoshev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
TreeView
Asked by
Jeremy
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Jeremy
Top achievements
Rank 1
Share this question
or