EasyUI Forum
May 20, 2024, 08:23:01 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: tree after reload, i can't select neither check node  (Read 16520 times)
fredk
Newbie
*
Posts: 6


View Profile Email
« on: January 23, 2014, 03:19:42 PM »

Hi

After reloading the tree, i can't select neither check the node

My case is : i select a node, i drop it. I would like to keep the select on the moved node, the one which has change place
I also try with the check method, doesn't work after reload method (works well elsewhere)

So i feel it's due to the reload ?

The basic code is:


 $('#tt').tree('reload');
 $('#tt').tree('select', source.target);
 $('#tt').tree('check', source.target);


I have tried with jquery promise, but it still doesn't work. Example:


 var reload = $('#tt').tree('reload');
 reload.promise().done(function () {
     var myNode = $('#tt').tree('find', source.id);

     alert(myNode) //OK, i get my good id

     //Select the node
     $('#tt').tree('select', myNode.target);
     //$('#tt').tree('select', myNode.id);
     //$('#tt').tree('select', myNode);
 });


But i make it works elsewhere , where there is no reload. Example:

success: function(idResult){
    //Find the node with id
    var nextNode = $('#tt').tree('find', idResult);

    //Select the node
    $('#tt').tree('select', nextNode.target);


If you have any ideas why and how to solve this

Thanks a lot
« Last Edit: January 25, 2014, 05:39:30 PM by fredk » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: January 23, 2014, 07:45:05 PM »

The tree can remain the 'checked' state during dragging and dropping. But after calling 'reload' method, the 'checked' state will be lost. You need to call 'check' method to check some nodes when reloading data successfully.
Logged
fredk
Newbie
*
Posts: 6


View Profile Email
« Reply #2 on: January 24, 2014, 11:11:36 AM »

Hi
thanks for the answer

My first need is to select the node , the check was just a second example to see if i have access or not on the node methods

My case is exactly this:
I am moving the node position with my keyboard
After each move i update the database and ajax:on success, i reload the tree (later i will reload only some nodes , but today, i relaod all)

I would like to keep the selection on the node to continue moving it with my keaboard, without re-selecting it with my mouse

Do you know why after reloading, i can't use the select method ?
I have been testing with a js timer, with promise, but ... i don't get it Sad
Cheers
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: January 25, 2014, 05:44:03 PM »

You need to store the id value of selected node before calling 'reload' method. When loaded successfully, you have to call 'select' method to select the previous selected node again.
Code:
var t = $('#tt');
var selectedNodeId;
t.tree({
onLoadSuccess:function(){
var node = t.tree('find', selectedNodeId);
if (node){
t.tree('select', node.target);
}
},
onSelect:function(node){
selectedNodeId = node.id;
}
});
t.tree('reload');
Logged
fredk
Newbie
*
Posts: 6


View Profile Email
« Reply #4 on: January 25, 2014, 05:56:53 PM »

Great thanks, it works Smiley
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!