TreeView error while attempting to append a node

2 posts, 0 answers
  1. Marion
    Marion avatar
    22 posts
    Member since:
    Nov 2016

    Posted 30 May Link to this post

    I am attempting to write the onDrop event:

    function onTreeDrop(e) {
            var treeview = $("#treeview").data("kendoTreeView");
            var p = e.dropPosition;
            
            sn = treeview.dataItem(e.sourceNode);
            dn = treeview.dataItem(e.destinationNode);
            psn = treeview.parent(e.sourceNode);
            pdn = treeview.parent(e.destinationNode);

            if (p == "over") {
                if (dn.IsDept) {
                    treeview.append(sn, pdn);
                }
                else {
                    treeview.append(sn, dn);
                }
                e.setValid(true);
            }
            else if (p == "before") {

            }
            else if (p == "after") {

            }
        }

     

    when I do a drop over I get the following error:

     

    kendo.all.js:78326 
    Uncaught TypeError: t.children is not a function
        at kendo.all.js:78326
        at init.append (kendo.all.js:79643)
        at init.onTreeDrop (Index:497)
        at init.trigger (kendo.all.js:124)
        at Object.drop (kendo.all.js:78557)
        at init.dragend (kendo.all.js:78269)
        at init.i (jquery-1.10.2.min.js:21)
        at init.trigger (kendo.all.js:124)
        at init._trigger (kendo.all.js:23904)
        at init._end (kendo.all.js:23881)

    when I follow the error to kendo.all.js:78326 the object has node.children. My own Model has a Children property. Perhaps the two "children" are conflicting?

     

     

    Index:497 Unc
    aught TypeError: t.children is not a function at kendo.all.min.js:66 at init.append (kendo.all.min.js:67) at init.onTreeDrop (Index:497) at init.trigger (kendo.all.min.js:25) at Object.drop (kendo.all.min.js:67) at init.dragend (kendo.all.min.js:66) at init.i (jquery-1.10.2.min.js:21) at init.trigger (kendo.all.min.js:25) at init._trigger (kendo.all.min.js:36) at init._end (kendo.all.min.js:36)
    Index:497 Uncaught TypeError: t.children is not a function at kendo.all.min.js:66 at init.append (kendo.all.min.js:67) at init.onTreeDrop (Index:497) at init.trigger (kendo.all.min.js:25) at Object.drop (kendo.all.min.js:67) at init.dragend (kendo.all.min.js:66) at init.i (jquery-1.10.2.min.js:21) at init.trigger (kendo.all.min.js:25) at init._trigger (kendo.all.min.js:36) at init._end (kendo.all.min.js:36)
  2. Dimitar
    Admin
    Dimitar avatar
    225 posts

    Posted 01 Jun Link to this post

    Hello Marion,

    On the following Dojo example you will find a working sample, which demonstrates how you can achieve the desired drag and drop between two TreeView widgets.

    You will notice that in the above example there is a e.PreventDefault() added in order to prevent the default event action.

    The other difference is that in order to get the node I have used the .toJSON() method to return a simple JavaScript object, which is needed because the dataItem() method returns an ObservableObject

    In addition to the above, the TreeView append() method accepts specific parameters, which you can find explained in details here. The second parameter is passed as an element:
    var destinationNode = $(e.destinationNode);

    I hope this helps you to resolve your issue. In case you have any other related questions, please do not hesitate to contact us.

    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top