Results 1 to 2 of 2

Thread: Reordering of the ContentPanels in VerticalLayoutContainer by Drag and Drop

  1. #1
    Sencha Premium Member
    Join Date
    Oct 2012
    Location
    Zurich, Switzerland
    Posts
    25

    Default Reordering of the ContentPanels in VerticalLayoutContainer by Drag and Drop

    I am implementing a drag&drop functionality for the VerticalLayoutContainer to reorder the ContentPanels which are embedded in it. As the basis I used the example from here http://www.sencha.com/examples/explo...Place:basicdnd

    Code:
    VerticalLayoutContainer mtgElementsPanel;
    ...
    DropTarget target = new DropTarget(mtgElementsPanel) {
                @Override
                protected void onDragDrop(DndDropEvent event) {
                    super.onDragDrop(event);
                    Widget wg = (Widget) event.getData();
                    mtgElementsPanel.insert(wg, 1); 
                    getMainContainer().forceLayout();
                }
    
            };
    Is there any way to determine the new position for the content panel to be dropped basing on my cursor? I would like to know the index for the dragged ContentPanel so that I can insert it between the existing widgets using insert method. In my example I use the hard-coded index 1.

    In the examples code, the add method is used which always adds the on the very end.

  2. #2
    Sencha Premium Member
    Join Date
    Jun 2013
    Location
    Nuremberg, Germany
    Posts
    88
    Answers
    3

    Default

    Hi jack83,

    have a look at the PortalLayoutContainer. There is a method onPortletDragMove, in which the target (portal) column an the row are calculated (methods getColumn(.) and getRowPosition(.)).

    I suppose you can't copy it without changes, but it basically works with absoluteTop and offsetHeight, which should be suitable for your problem, too.

    Please let me know if this helps for you.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •