Hello
I'm evaluation WebDataTree and I've the following questions
Drag and Drop -
1. Restrict user from dropping a node between/before/after etc. I want the user to drop a node only on another node.
2. Completely hide indicators while dragging (not formatting the message).
Context Menu
1. How to show context menu?
2. Can different menus be given to different nodes (menu items change based on the node)?
Load on demand
1. Bind data to some levels based on demand?
2. Any paging available in the tree?
Regards
NLV Raghavendra
Hi,
there are no server side events for those events you have listed. The only server side event available is node dropped. It will fire for every drop that happened on the client. You can do two things one solution is to store the info that you want to vaidate somewhere in the client. For example in the node.value field. And then attach to the client side NodeDropping event and pull out the node.value and check you condition there. If you do not want the drop to happen cancel the NodeDropping event. The other solution is much more complex. When on postback you can attach to NodeDropped on the server and log the nodes for which this event fired and then, rearrange the node on the server to their inital positions. before the drops. I.e. you cancel those drops. Also you can configure with flags whether some node is draggable or not. If it is not draggable, the user will not be able to start a drag operation on it.
You can also configure an AutoPostBack flag for NodeDropped to be On so that you can check on the server after each drop whether it is OK or not and to revert the change using the serverside collections.
Hope this helps.
Thanks,
Lubomir
Is there dragEnter, DragOver server side events
in webdatatree?
i have to validate the drooped target of the destination node from the database.
so how can i do that at client side, i am using webdatatree 10.3 version.
Hello,
about Drag & Drop
1) Yes you can restrict which nodes the user can drag in the initialize event of the tree by setting the following:
node._getFlags().setDraggable(false); - this will prevent the node from being able to be dragged.
you can use node._getFlags().getDraggable() to check this flag value.
Another way for controlling where one node could be dropped on another node is to subscribe for the DragEnter event and to check some condition and to cancel the event.
function onDragEnter(sender, args) { if (args.get_destNode().get_valueString() == "File") { args.set_cancel(true);
return; } // do something }
Another way is to subscribe for the NodeDropping event and to check whether the location of the drop is acceptable and if not to cancel the event.
In the NodeDropping event from the args you can get the following:
get_sourceNodes() - returns an array of nodes that are being dragged.
get_sourceTreeId() - returns the client ID of the tree that the source nodes came from.
get_dragDropEffect() - returns the drag drop effect - is it move or copy.
get_dragDropPoint() - returns the point where the nodes are dropped. This is an enumeration having the following values On, Before or After. On - the node is dropped over the destination node. After - the nodes are dropped after the destination node. Before - the source nodes are dropped before the destination node.
get_destNode() - returns the destination node object.
So to summarize about D&D you have plenty of choices to configure the desired behavior you want. In a future release we are planning to add Dragable and Dropable properties to server side Node object so that you can configure this in the markup too.
About 2) you can hide the drop indicator by setting Visible = false to the DropInidcator property of the DragDropSettings property of the tree.
Context Menu:
you can show a context menu by using a WebDataMenu control. You have to put a menu on the page and set its IsContextMenu property to true. Then when you want to show the menu in a node click event of the tree, you can say the following:
function Node_Click(tree, eventArgs) { lastNode = eventArgs.getNode(); var menu = $find("<%= ContextMenu.ClientID %>"); if (menu != null && eventArgs.get_browserEvent() != null && eventArgs.get_browserEvent().button == 2) { menu.showAt(null, null, eventArgs.get_browserEvent()); } }
You can check the WebDataMenu -> Context Menu sample on http://samples.infragistics.com/2010.3/WebFeatureBrowser/Default.aspx
2) Yes you can have different menu controls rendered as context menus on the page and show them depending on the conditions you want. You can also use one menu and use the menuItem.set_visible(false/true) - to show hide some of the items of the context menus. You can also use menuItem.set_enabled(true/false) - to enable/disable some of the menu items.
About Load On Demand:
1) You can configure how much levels do you want to be binded on initial load by setting InitialDataBindingDepth property. Its default value is -1 which means all levels are bound. But if you configure it to 0 - only the first level will be bound, if you set it to 1 - first and second level will be bound and etc.
2) I do not get what do you mean by paging in the tree, if you mean like grid paging, there isn't similar feature in the tree, but you could talk to product management and describe your need for such feature.
ASP.NET R&D Team Lead