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

[Solved] LoadOnDemand Callback function of Javascript

2 Answers 80 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tran
Top achievements
Rank 1
Tran asked on 07 Oct 2011, 03:55 AM
Hi all , 
I'm working with treeview control of Telerik ASP.NET MVC .
Currently , I have faced with an issue.Because I use LoadOnDemand on my treeview and I want to select one child element after expanding parent element.
I use JavaScript function to do it. But I can't find any child element because tree view does not finish its loading.

Here is my temp solution : I use setTimeout and set time is 1000 ms
function selectChildNode{
////do some thing
   parentNode.expand();
setTimeout(function (){
//do something
select(childNode);

},1000);

}

I think the below solution is not good because we have to depend on time (1000 ms).

I hope we have a callback function for this. But I can't find out something like that.

Anyone can help me to give other solution ?

Thanks all so much.

2 Answers, 1 is accepted

Sort by
0
Andrew
Top achievements
Rank 1
answered on 20 Dec 2011, 11:49 AM
I have exactly the same problem. I have the full path of an element in the treeview, but the "load on demand" is activated.

I try to do this :

function expandToNode(fullpath){
    var treeview = $('#tvitems').data('tTreeView');
    $('#tvitems').find(".t-state-selected").each(function(){
        $(this).removeClass("t-state-selected");
    });
    nodes = fullpath.split('|');
    for (index in nodes)
    {
        var nodeValue = nodes[index];
        var tvNode = treeview.findByValue(nodeValue);
        treeview.expand(tvNode);
    }
 
}

But this code only expand the first node of the path.
How to get the callback of the ajax request to launch the second expand etc... ?

Thank you in advance !
0
Andrew
Top achievements
Rank 1
answered on 20 Dec 2011, 01:50 PM
Tags
General Discussions
Asked by
Tran
Top achievements
Rank 1
Answers by
Andrew
Top achievements
Rank 1
Share this question
or