3.2.0

Get index of first & last visible row in grid.

Is it possible to get the index of the first and last row that are visible in the grid?

Calling getScrollProperty('top') returns pixel position of top row but the rows in my grid do not all have the same height, so it is difficult to determine the row index from the pixel offset.
April 17,
I mean, I know the following code will work when all rows in the grid have the same height:

var visTop = tbl.getScrollProperty("top"); 
    var rowHeight = tbl.getRowHeight();
    var visHeight = tbl.getContentHeight(1);
    var firstVisRow = visTop/rowHeight;
    var lastVisRow = (visTop + visHeight) / rowHeight;


But what if the row heights are not all the same? Is there an alternative?
CK
April 18,
AW grid currently does not support variable row heights - they must be the same otherwise scrolling will not work.
Alex (ActiveWidgets)
April 19,
But I'm already using variable row heights !

tbl.defineRowProperty("custom_height", function(row){ 
        return getCustomRowHeight(tbl,row);});
    tbl.getRowTemplate().setStyle("height", function(){ 
        return this.getRowProperty("custom_height");});


And for scrolling I compute an average row height and then call tbl.setRowHeight(avgRowHeight).

So my problem is how to determine which rows are currently visible when scrolling, without needing to check all the individual row heights starting at row zero each time.
CK
April 19,
BTW, the variable row height code I listed above has been working for years and still works fine.

My question about determining which rows are currently visible relates to a different issue.
CK
April 19,

This topic is archived.

See also:


Back to support forum