This is a migrated thread and some comments may be shown as answers.

[Solved] popup positioning after vertical scrolling in grid not correct

1 Answer 86 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Gerard Eikelboom
Top achievements
Rank 1
Gerard Eikelboom asked on 24 Dec 2010, 11:07 AM
Hi,
I am using the Grid and I am stuck on something.
See enclosed pictures.
The point is, when I click on a button in my grid it comes up with a popup (see popup good).
As long as I dont use the vertical scrolbar it sets itself at the correct position.
When I use the vertical scrolbar the popup appears in at the wrong place. The more I scroll the worse it get (see bad popup).
Under a piece of code how i position the popup.
$("#popupkoopbox").css({ 'left': leftVal, 'top': topVal, 'position': 'relative', 'display': 'block' });

var leftVal = offset[0] - 180 + "px";
var topVal = offset[1] - 230 + "px";

function getPosition(obj) {
            var topValue = 0, leftValue = 0;
            var finalvalue = new Array();
            var gridcontentheight = $('.t-grid-content').height();
            while (obj) {
                leftValue += obj.offsetLeft;
                topValue += obj.offsetTop;
                obj = obj.offsetParent;
            }
            finalvalue[0] = leftValue;
             finalvalue[1] = topValue;
             return finalvalue;
        }

I hope there is someone who can get me a push in the right direction

Regards,
Gerard

1 Answer, 1 is accepted

Sort by
0
Gerard Eikelboom
Top achievements
Rank 1
answered on 11 Jan 2011, 11:24 AM
I found the solution for this in my getposition method:

function getPosition(obj) {
            var topValue = 0, leftValue = 0;
            var finalvalue = new Array();
            var gridcontentheight = $('.t-grid-content').height();
            var elem = $('.t-grid-content');
            while (obj) {
                leftValue += obj.offsetLeft;
                topValue += obj.offsetTop;
                obj = obj.offsetParent;
            }
            var scrollheight = elem[0].scrollTop;
            topValue = topValue - scrollheight;
            finalvalue[0] = leftValue +10;

Using this it doen't matter if you scroll in your grid en showing a popup. It stays on the place where I clicked.
Tags
Grid
Asked by
Gerard Eikelboom
Top achievements
Rank 1
Answers by
Gerard Eikelboom
Top achievements
Rank 1
Share this question
or