Jump to content

UniDBGrid Get Cell By X Y Position


SilvaM

Recommended Posts

Hi!

 

I need to select a cell (or a row) in a UniDBGrid using XY Position. 

 

How could I implement something like this:

 

Ext.override(Ext.grid.GridView, { 

    /** 
     * Returns a cell row, col, and element, by the xy coodinates 
     *  
     * @param {Integer} x 
     * @param {Integer} y 
     * @returns {Array} [row, col, el] 
     */ 
    
getCellByXY: function(xy) { 
        var 
view this
            
rows view.getRows(); 
         
        
//loop rows 
        
for (var 0rows.lengthi++) { 
            var 
0cell
            
//loop cells in row 
            
while (cell view.getCell(ij)) { 
                var 
cellEl Ext.get(cell); 
                 
                if (
cellEl.getTop() <= && cellEl.getBottom() >= y) { 
                    if (
cellEl.getLeft() <= && cellEl.getRight() >= x) { 
                        return [
ijcell];  
                    } 
                } else { 
                    
//prevent useless cell loops in wrong row 
                    
break; 
                } 
                 
                
j++; 
            } 
        } 
         
    } 
}); 

 

Link to comment
Share on other sites

Yes, I need to select the row in the XY mouse coordinates.

 

Hi SilvaM.

 

If I understand correctly, try:

 

UniDBGrid1 -> ...

function itemmouseenter(sender, record, item, index, e, eOpts)
{  
  if (sender.getSelectionModel()) {
    sender.getSelectionModel().select(index)
  }; 
}

Works correctly when:

 

1. Grouping.Enabled := False;

2. Options, dgRowSelect := True;

 

Best regards.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...