EasyUI Forum
May 08, 2024, 02:07:18 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 node dataformat  (Read 13797 times)
fl0
Newbie
*
Posts: 10


View Profile
« on: May 15, 2013, 05:25:58 AM »

Hi,

i work with copy and paste on a tree (since u haven't fixed my other problem so far Wink ) and i got a little problem with the format of the datainput

i copy a node (with children OR without) by

Code:
clipboard = t.tree('getData', node.target);

therefore i get a single json object. But when i want to append the copied node by

Code:
        t.tree('append', {
            parent: (node ? node.target : null),
            data: clipboard
        });

the tree requests an array object. I know i could work around by using [clipboard] but there is where it stands in conflict with another possibility i want to offer: pasting only children.
To accomplish that i change the clipboard
Code:
clipboard = clipboard.children;
Now i dont know if i got an array or a single item. Of course i could work around that but maybe u could modify the datainput to accept single json data as well as arrays of json data.

If you could tell me early if you plan on changing that would be great because i want to finish the program soon Smiley and otherwise i have to implement the workaround myself
Logged
fl0
Newbie
*
Posts: 10


View Profile
« Reply #1 on: May 15, 2013, 05:54:01 AM »

ok problem is not relevant anymore. it got more complex so i had to work around anyway Smiley but you could still fix it for others
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #2 on: May 15, 2013, 09:01:00 AM »

Yes, the updated tree plugin is available from http://www.jeasyui.com/easyui/plugins/jquery.tree.js. Once you get a node data.
Code:
clipboard = t.tree('getData', node.target);
To append it to another node, you can write:
Code:
        t.tree('append', {
            parent: (node ? node.target : null),
            data: [clipboard]
        });
or
Code:
        t.tree('append', {
            parent: (node ? node.target : null),
            data: clipboard
        });
Logged
fl0
Newbie
*
Posts: 10


View Profile
« Reply #3 on: May 23, 2013, 11:57:19 PM »

Back at the problem. Are you sure it is working?


JSON.stringify(clipboard) => {"id":"2","text":"Stuff","attributes":{"his":"2","status":0},"target":{"jQuery18206816951613443558":166,"pageY":329},"checked":false,"state":"closed","children":[]}

But

Code:
t.tree('append', {
            parent: (node ? node.target : null),
            data: clipboard
        });

still not working after update, while

Code:
t.tree('append', {
            parent: (node ? node.target : null),
            data: [clipboard]
        });

works...
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!