Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    DnD within the same table - How to know where it is dropped ?

    Hi,

    Using drag and drop within the same table provides two methods to get the dragged node:

    
    Code:
    public void onDrop( DropEvent event )
    {
    	TreeGrid source = (TreeGrid) EventHandler.getDragTarget();   
    	
    	// or
    
    	TreeGrid source = (TreeGrid) event.getSource();
    }
    But, how can you know the node where it is dropped ? I didn't find it in the Javadocs (I know, I know, it must be evident, but really, I didn't find it)

    Thanks in advance,
    Juan

    #2
    getEventRow()

    Comment


      #3
      Thank you. It's working.

      Comment


        #4
        Identity drop target action

        With the method getEventRow(), we can get the target record in the TreeGrid (getRecord(getEventRow())). But the thing is that it does not identify if the drop target is below/over/append (like in GWT-Ext).
        Say I have the following tree:
        A
        --A1
        --A2

        Where A1 and A2 are children nodes of A.

        If I want to drag an external node (from a ListGrid) and drop it between A1 and A2, I'll sometimes get the A1 and sometimes the A2 (depending on the pixel where the cursor is) as target, but will have a line indicating that the drop is between both. How do I know if i'm trying to drop between both (as a child of A), or append it as a child of A1?

        By the way, I am not able - when moving around a node - to add it as a child of a leaf. Does anyone know why?

        Comment


          #5
          fyi ListGrid.addRecordDropHandler has been added to SVN. Similarly TreeGrid.addFolderDropHandler has also been added.

          Code:
          countryGrid2.addRecordDropHandler(new RecordDropHandler() {
              public void onRecordDrop(RecordDropEvent event) {
                  ListGridRecord[] records = event.getDropRecords();
          
                  //index of the record being droppped on
                  int index = event.getIndex();
              }
          });
          Sanjiv

          Comment

          Working...
          X