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

Append item - Success Callback not working

1 Answer 135 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Dirk
Top achievements
Rank 1
Dirk asked on 19 Aug 2013, 07:19 AM
Hello Kendo UI Team,

I'm trying to add and select a new item to a treeview with remote datasource. This works as long as the branch of the tree is already loaded. If the branch is not loaded, the append-method returns null as documented. I tried to add a success callback method but it seems as if it is never called.

function createNewItem() {
    var tree = $("#dvTree").data("kendoTreeView");
    var selected = tree.dataItem(tree.select());
    var newnode = { text: '<new>', type:itemtype };
    newelement = tree.append(newnode, $(tree.select()), function () { alert("success"); });
   
    console.log(newelement);
 
    if (newelement) {
        tree.select(newelement);
        tree.trigger("select", { node: newelement });
    }
}
Am I trying a wrong approach here? Kendo UI Version is 2013.2.716.

Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 21 Aug 2013, 07:48 AM
Hello,

You could either clear the current selection and set the selected property of the new node to true:

tree.append({text: '<new>', type:itemtype, selected: true},  tree.select());
or use the select method in the dataBound event in order to select the new node e.g .
tree.one("dataBound", function (e) {
    setTimeout(function () {
        treeview.select(node.find(".k-item:last"));
    });           
});
tree.append({  text: '<new>', type:itemtype }, tree.select());
Regards,
Daniel
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
Dirk
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or