This bug is happening only on Free jqGrid 4.9.0 (When I'm switching back to Free-jqGrid 4.8.0 all is working well).

I couldn't recreate it on jFiddle, so it might be due to the fact I have multiple grids on the same page (maybe).

The bug:

The advance search dialog have thier style 'top' and 'left' defaulted to 0px both, so that they apear by default at the upper left of the grid when user click on the search button.

Now, if you close the dialog, and click on the search button again, the 'top' and 'left' are being re-calculated somehow, and the dialog goes up -228.1875px for 'top' and -5px for 'left'. the next time I repeat this flow, the dialog just vanished from the screen (cause it gets -500px or something).

This happens on all my 5 grids. Same behavior. the dialog keeps re-calculate it's position with every re-opening.

I started doing reverse engineering to find out where are those lines in 4.9.0 that cause to this behavior, and found out it's due to the function savePositionOnHide (line 9896 in jquery.jqgrid.src.js), within the block: this.data(propName, {

if I replace:

top: top,                 //parseFloat($w.css("top")),
left: left,               //parseFloat($w.css("left")),

with

top: getCssStyleOrFloat($w, "top"),             //parseFloat($w.css("top")),
left: getCssStyleOrFloat($w, "left"),               //parseFloat($w.css("left")),

That I copied from 4.8.0, all is working well.

So I was just wondered, if this indeed a bug, or something else I'm missing.

Thanks,

1

There are 1 answers

0
Oleg On BEST ANSWER

Thank you for the bug report and the demo which demonstrates the problem! I agree that the code is buggy. I fixed the code of savePositionOnHide (see here) from

savePositionOnHide = function (propName, frmgr, h) {
    var $w = h.w, $form = $(frmgr), toTop = h.c.toTop, offsetGbox,
        top = getCssStyleOrFloat($w, "top"),
        left = getCssStyleOrFloat($w, "left");
    // we use below .style.height and .style.width to save correctly "auto" and "100%" values
    // the "px" suffix will be saved too, but it's not a problem 
    if (toTop) {
        offsetGbox = $w.closest(".ui-jqgrid").offset();
        top -= offsetGbox.top;
        left -= offsetGbox.left;
    }
    ...
}

to the following

savePositionOnHide = function (propName, frmgr, h) {
    var $w = h.w, $form = $(frmgr), toTop = h.c.toTop, offsetGbox, offset, top, left;
    if (toTop) {
        offsetGbox = this.closest(".ui-jqgrid").offset();
        offset = $w.offset();
        top = offset.top - offsetGbox.top;
        left = offset.left - offsetGbox.left;
    } else {
        // we use below .style.height and .style.width to save correctly "auto" and "100%" values
        // the "px" suffix will be saved too, but it's not a problem 
        top = getCssStyleOrFloat($w, "top");
        left = getCssStyleOrFloat($w, "left");
    }

and committed the changes to the main code on GitHub. The demo which you posted use the code from GitHub directly and it start work correctly after I committed the fix.