1. #1
    Sencha User
    Join Date
    Apr 2010
    Posts
    18
    Answers
    1
    Vote Rating
    0
    vbjain is on a distinguished road

      0  

    Default Answered: Grid removing the model from store on Drag and Drop

    Answered: Grid removing the model from store on Drag and Drop


    Hello,

    My requirement is when i drag drop on same Grid i should get the original index of dragged element and also the original index of dropped element as in the Grid's Store.

    But i can see that when i drag an element from Grid that element is now been in Grid's Store anymore. Can you tell me how to stop this function?

    As you can see i have overridden all the DnD events for my custom code. Still i dont know why i am getting this behavior from grid.

    Below is the code.

    Code:
    /* Drag support */
    GridDragSource documentDragSource = new GridDragSource(myGrid);
    documentDragSource.addDNDListener(new DNDListener() {
       @Override
        public void dragStart(DNDEvent pDNDEvent) {}
    });
            
    /* Drop support */
    GridDropTarget gridDropTarget = new GridDropTarget(myGrid);
    gridDropTarget.addDNDListener(new DNDListener() {
       @Override
        public void dragDrop(DNDEvent pDNDEvent) {
            DragSource dragSource = pDNDEvent.getDragSource();
            if (dragSource instanceof GridDragSource) {
                Grid grid = ((GridDropTarget)pDNDEvent.getDropTarget()).getGrid();
                
                List<AbstractContentItem> selectedItems = pDNDEvent.getData();
                int dragElementIndex = 0;
                //here i am getting -1 only
                dragElementIndex = grid.getStore().indexOf(selectedItems.get(selectedItems.size() - 1));
                
                int rowIndex  = grid.getView().findRowIndex(pDNDEvent.getDragEvent().getTarget());
                if (dragElementIndex < rowIndex) {
                    rowIndex =  rowIndex - 1;
                }
                AbstractContentItem contentItem = (AbstractContentItem)grid.getStore().getAt(rowIndex);
                presenter.setSelectedNode(contentItem.getParentFolderDTO(), contentItem.getDTO());
            }
            presenter.pasteContent();
    }
    
       @Override
         public void dragEnter(DNDEvent pDNDEvent) {}
    
       @Override
          public void  dragMove(DNDEvent pDNDEvent) {}
    
    });
    gridDropTarget.setAllowSelfAsSource(true);

  2. Set the Operation to COPY. I set it as MOVE.

  3. #2
    Sencha User
    Join Date
    Apr 2010
    Posts
    18
    Answers
    1
    Vote Rating
    0
    vbjain is on a distinguished road

      0  

    Default Resolved

    Resolved


    Set the Operation to COPY. I set it as MOVE.