3.2.0

Absolute position of a row?

Is it possible to get the absolute left,top position of a grid row?
Karl Thoroddsen
September 11,
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)
September 12,
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
September 13,
:-(

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)
September 13,
Thanks Alex.
Karl Thoroddsen
September 13,

This topic is archived.

See also:


Back to support forum