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

Problem with callback-function of the expandPath-function

1 Answer 70 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Xaver
Top achievements
Rank 1
Xaver asked on 04 Mar 2015, 01:33 PM
Hi,

I have problems with the callback-function of the expandPath-function.
Is it possible that this callback-function is not executed, when the path-Array (first parameter of the expandPath-function) is [0]?

What i am trying to implement is when a new child-item is created then the parent-item should be reloaded and after that the new child-item should be selected.
This works fine, only when this new item is child of the root-item (with id 0) the callback-function, which selects the item, is not executed.

var parentItem = wpTreeView.dataSource.get(parentId);
parentItem.expanded = false;
parentItem.loaded(false);
parentItem.hasChildren = true;
 
wpTreeView.expandPath([parentId], function () {
    var newItem = wpTreeView.dataSource.get(data.Id);
    var newListItem = wpTreeView.findByUid(newItem.uid);
    console.log(newListItem);
    wpTreeView.select(newListItem);
});


Can someone give me some advice?

Regards,
Xaver

1 Answer, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 06 Mar 2015, 09:34 AM

Hello Xaver,

The expandPath method expects that the id can be found in the TreeView DataSource via get. If the parent item can be found, it will be expanded.

Given the code that you posted, it could be that the newly created item is not loaded from the server, or that its uid is changed (because the data item has changed). Please verify that the item is correctly found prior to selecting. If you need help with this, please submit a sample that shows the problem.

Regards,
Alex Gyoshev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
TreeView
Asked by
Xaver
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Share this question
or