EasyUI Forum

General Category => Bug Report => Topic started by: fl0 on May 15, 2013, 05:25:58 AM



Title: Tree node dataformat
Post by: fl0 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 ;) ) 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 :) and otherwise i have to implement the workaround myself


Title: Re: Tree node dataformat
Post by: fl0 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 :) but you could still fix it for others


Title: Re: Tree node dataformat
Post by: stworthy 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
        });


Title: Re: Tree node dataformat
Post by: fl0 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...