Results 1 to 3 of 3

Thread: Get grid rowIndex on drop

  1. #1
    Ext User torvad's Avatar
    Join Date
    Jul 2007
    Location
    Sweden
    Posts
    7
    Vote Rating
    0
      0  

    Default Get grid rowIndex on drop

    Hi,
    I've been searching the forum but no luck so far.

    I have a tree from which I drag tree leafs to a grid. On then event handler for noifyDrop on the grid I am trying to get the index of the row that I'm dropping my tree data on. I need the rowIndex for my insert in the datastore.

    I've tryed few things I've found in the forum, but I think they all were regardning D&D within/between grids. I am new to ext and the javascript model so I the answer is obvius, I can't see it.

    (I'm using xsl/xml to create components)

    My code:
    Code:
    var ddrow = new Ext.dd.DropTarget(grid.container, { 
    ddGroup : '<xsl:choose><xsl:when test="@ddGroup"><xsl:value-of select="@ddGroup"/></xsl:when><xsl:otherwise></xsl:otherwise></xsl:choose>', 
    copy:false, 
    notifyDrop : function(dd, e, data){ 
    		
    if(!data.node)
    {
    //DEBUG
    //alert('handle internal grid DD or sort');
    				
    var sm=grid.getSelectionModel(); 
    var rows=sm.getSelections(); 
                
    var cindex=dd.getDragData(e).rowIndex; 
    
    for (i = 0; i <xsl:text disable-output-escaping="yes"><![CDATA[<]]></xsl:text> rows.length; i++) { 
    rowData=JsonData.getById(rows[i].id); 
    if(!this.copy) { 
    JsonData.remove(JsonData.getById(rows[i].id)); 
    JsonData.insert(cindex,rowData); 
    } 
    }; 
    }
    else
    {
    //DEBUG
    //alert('drop from tree ' + data.rowIndex);
    
    //HERE is by head scratcher!!!!
    var cindex=0;//dd.getDragData(e).rowIndex; 
    			
    var rowData = new RecordDef({
    				
    <xsl:for-each select="sx:ext-grid-column/sx:ext-grid-cm">
    				
    <xsl:if test="position()&gt;1">,</xsl:if>
    <xsl:value-of select="@dataIndex"></xsl:value-of>:'1'
    </xsl:for-each>
    });
                	
    if(!this.copy){ 
    JsonData.insert(rowIndex, rowData); 
    }
    else{
    alert('is a copy');
    return false;
    }
    }
    			
    } 
    });

  2. #2
    Ext User torvad's Avatar
    Join Date
    Jul 2007
    Location
    Sweden
    Posts
    7
    Vote Rating
    0
      0  

    Smile Solved

    Hi,
    I found the ansver in vtswingkids thread.
    http://extjs.com/forum/showthread.php?t=9390



    Add the following to your grid definition:
    Code:
    listeners:{
    scope:this,
    'mouseup':{scope:this.grid, fn:function(e, t){
    var row;
    if((row = this.view.findRowIndex(t)) !== false)this.rowMouseUp=row;
    else this.rowMouseUp=false;
    }}
    }
    Then in notifyDrop:
    Code:
    var cindex=grid.rowMouseUp;
    Got the index

  3. #3
    Ext User
    Join Date
    Jun 2007
    Posts
    16
    Vote Rating
    0
      0  

    Talking

    Brilliant!

    Thanks. That's solved my problem with row selection before I even posted it!

    Ben

Posting Permissions

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