Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
135
Questions with drag and drop, context menu, load on demand
posted

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

Parents
No Data
Reply
  • 3726
    Suggested Answer
    posted

    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.

    Hope this helps.

    Thanks,

    Lubomir

    ASP.NET R&D Team Lead

     

     

     

     

Children