:: Forum >>

Vertical scrollbar positioning in Firefox/safari vs chrome/ie.

In Firefox and safari, the scrollbar for my grid starts from the header, wheareas in chrome/IR, it starts from the first row of data. Is there anyway I can fix it in Firefox/Safari to have it start from the first row as well. I assume there is a css fix for this ... but I'm not sure how that works.

I'm trying to figure out the index of the first and last visible rows. I tried to follow the example shown in this thread: http://www.activewidgets.com/javascript.forum.26139.4/get-index-of-first-last.html

But it hasn't worked out completely. It calculates correctly when the scrolltop value is 0 (scrollbar is at the top). But the moment I start scrolling downwards, the calculations go awry, and the calculated pagestart number is less than that of the row position of the top visible row, with the gap increasing as I scroll further.

var topVisible = grid.getScrollProperty("top");
    var rowHeight = grid.getRowHeight;

    var pageStart = (topVisible == 0) ? 1 : Math.ceil(topVisible / rowHeight);

    // frmSize() is a custom function that gets frame height. Grid height set to 100%
    var rowsPerPage = Math.ceil(frmSize() / rowHeight);
    
    var pEnd = pageStart + (rowsPerPage - 1);
    var pageEnd = (pEnd > myData.length) ? myData.length : pend;

    document.getElementByID('pageLabel').innerHTML = " " + pageStart + " - " + pageEnd + " of " + myData.length



I've tried many permutations of this code, but still can't shake the issue.
Any help would be appreciated.
Sam H
Friday, May 11, 2012
Resoved this. I had to refer to the grid-box height to get my calculations correct. If anyone has a better way of doing this, please let me know.

var topVisible = grid.getScrollProperty("top");
    var gridHeight = document.getElementById("grid-box").clientHeight;
    var scrollHeight = grid.getScrollHeight();
    var rowHeight = scrollHeight / myData.length;
    var rowsPerPage = Math.floor(gridHeight / rowHeight) - 2; //account for header and scroll rows

    var pageStart = (topVisible == 0) ? 1 : Math.ceil(topVisible / rowHeight) + 1; //account for header

    var pEnd = pageStart + rowsPerPage;

    var pageEnd = (pEnd > myData.length) ? myData.length : pEnd;

    var pageNumber = (myData.length <= rowsPerPage) ? 1 : Math.ceil(pageStart / rowsPerPage);
    
    document.getElementById('pageLabel').innerHTML = " " + pageStart + " - " + pageEnd + " of " + myData.length;
    document.getElementById('pageDirect').innerHTML = "Page " + pageNumber;

Sam H
Monday, May 14, 2012

This topic is archived.


Back to support forum

Forum search