:: Forum >> Version 2 >>

Absolute position of a row?

Is it possible to get the absolute left,top position of a grid row?
Karl Thoroddsen
Monday, September 11, 2006
There are two internal method which could help - AW.left(element) and AW.top(element), the argument should be DOM node, i.e.

var top = AW.top(grid.getRowTemplate(rowIndex).element());

or for the extended grid

var top = AW.top(grid.getRowTemplate(rowIndex, 0).element());
Alex (ActiveWidgets)
Tuesday, September 12, 2006
Thanks Alex but I got an 'unknown method' for AW.top?

Anyway this returned the top value I was looking for:

var ypos 0;
var 
gridrow itsGrid.getRowTemplate(row).element();
while (
gridrow != null)
{
  
ypos += gridrow.offsetTop;
  
gridrow gridrow.offsetParent;
}
 
Which is probably similar to the 'top' method?
Karl Thoroddsen
Wednesday, September 13, 2006
:-(

sorry, it should be AW.getTop(element) and AW.getLeft(element).

IE:

AW.getLeft = function(element){
    return 
element.getBoundingClientRect().left;
};

AW.getTop = function(element){
    return 
element.getBoundingClientRect().top;
};
 
Firefox:

AW.getLeft = function(element){
    var 
doc document.getBoxObjectFor(document.body);
    return 
document.getBoxObjectFor(element).screenX doc.screenX doc.x;
};

AW.getTop = function(element){
    var 
doc document.getBoxObjectFor(document.body);
    return 
document.getBoxObjectFor(element).screenY doc.screenY doc.y;
};
 
Your code will also work most of the time but it is less reliable in some extreme cases due to the offsetParent bugs.
Alex (ActiveWidgets)
Wednesday, September 13, 2006
Thanks Alex.
Karl Thoroddsen
Wednesday, September 13, 2006



This topic is archived.

Back to support forum

Forum search