EasyUI Forum
May 17, 2024, 08:11:48 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: how to select a specific node after a tree load  (Read 8453 times)
gregma
Newbie
*
Posts: 2


View Profile
« on: September 02, 2014, 02:45:40 AM »

hi
  I am using the tree control. the following codes does not select the node I want. I guess this is due to the async nature of the tree control: when 'find' method is executed, the tree's data may not arrive yet. I tried other ways such as placing the 'select' method in the formatter function, but none of them seems to work. Do you guys know how to do it? Thanks in advance.

    var g_node_id = 11;
    $('#tt').tree
    ({
      url: "<c:url value='/student/classlist'/>",
      method:'get',
      ...
    });

    var node = $('#tt').tree('find', g_node_id);
    if (node)
      $('#tt').tree('select', node.target);
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: September 02, 2014, 06:10:55 PM »

Please try this:
Code:
$('#tt').tree({
url: "<c:url value='/student/classlist'/>",
method:'get',
onLoadSuccess:function(){
var node = $(this).tree('find', g_node_id);
if (node){
$(this).tree('select', node.target);
}
}
})
Logged
gregma
Newbie
*
Posts: 2


View Profile
« Reply #2 on: September 02, 2014, 08:31:13 PM »

Please try this:
Code:
$('#tt').tree({
url: "<c:url value='/student/classlist'/>",
method:'get',
onLoadSuccess:function(){
var node = $(this).tree('find', g_node_id);
if (node){
$(this).tree('select', node.target);
}
}
})

Wow, You are a great help! Thanks a lot!
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!