Hi,
My Version: 2008 vol 1 for CLR 3.5
When I try to drag and drop a Node that has children from one WebTree to another, only the current node is dropped on the target. Any child node on the source node is not dropped on the target. I have checked your sample which also behaves the same way. Does that mean I cannot move or copy a Node alongwith it's children? That doesn't sound right. If I need to change the javascript function to achieve that, could you please show me a sample script that can do it? I am not a guru on java script.
Thanks.
Hi Rajan,
I haven't reached as far as updating the database on the server side yet. But I can tell you the way I intend to do it.
I have two trees on the page. One is a generic tree for product categories that is system wide. The other is a customized category tree with selected products. I am dragging categories (which may or may not contain sub categories) on to the custom Category tree. In the Node drop client event, I store the primary key and the table name it came from into three list boxes on the same page but these controls are hidden. If I dropped new nodes from the source tree, I add them to the "Added" list box. If I deleted the node(s), I add them to the deleted list box. If I re-arranged the nodes within the same tree, I add them to the "Modified" list box. Then, on the "Save" button click of the form, I update the database using these three list boxes. That way, I do not need to walk the whole bunch of tables in the database (they are huge). Just update the items in the three list boxes.
By the way, though I have been programming with C# for over 8 years now, I am new to JavaScript. Thats what was holding me down so far. But I think I tackled all the client side problems and now I am beginning to tackle the Server side which I hope is a breeze.
I hope this helped you in some way! May be if you store the node IDs in a similar hidden field, you could act on them when you need to.
Babu.
Nope i dint write it...but good you got it and worked for it.
But i have a question, when you drag it to another tree and updates the DB for this drag, how do you maintian the State of the tree. I am doing the same thing, though on the same tree, but when i update the tree for the drag on server and comeback, i would have to load the tree in the same state where it was before drag, but only dragged nodes will appear on another location. I hope this does make sense. I habe nailed every option but still no success.
Raj
Thanks Rajan,
This is exactly what I did. I found the exact same function on the forum, implemented it and it works fine. If you wrote this function, thanks a lot for it.
I have no idea how you are dropping from one tree to another, but i guess you have to loop thjrough the children of the dragged node and then add this to another tree.
Please try this
function AddChildNodesRecursive(childNode, parentNode) { var newChild = parentNode.addChild(childNode.getText()); if (childNode.hasChildren()) { var children = childNode.getChildNodes(); for (c in children) { var childSubNode = children[ c ]; AddChildNodesRecursive(childSubNode, newChild); } } }