0

I recently upgraded my jqGrid from an older version (4.4.5) up to (4.13.4-pre)

"autowidth": false,
"shrinkToFit": true,
"loadonce": true,
"scroll": 1,

FWIW - I'm using it inside a paneled layout (acheived via jQuery UI Layout )

Everything works great, both versions initially load up my data and display nicely - no need to change my startup grid options or colModel etc..

enter image description here

However, if I hover my mouse over the data region and use the wheel to start scrolling through the data, eventually the 4.13.4 version of the jqGrid will flicker or refresh to build up the next page of data and that's when it introduced the undesired scrollbar state shown here:

enter image description here

I have some resizing logic already in place so that when the parent panel is resized, the grid snaps into correct position - same for when the user resized the window. All of that functions just as well on both versions of jqGrid -

Just wondering if there was something I missed in the meantime - I feel like I've uncovered a bug, however.

UPDATE

I've been able to isolate the jqGrid control from the aforementioned jquery UI Layout scripts. The bad behavior persists.

When the page is finished loading, I call a script like this to "patch up" the width and size of my jqGrid so it fits inside a desired parent DIV:

function patchUpJQGrid_FitInParentDiv() {
    var newWidth, newHeight, myGridCtrl;

    myGridCtrl = $("#mainGridControl");

    newWidth = $("#parentMainGridDiv").width() - 50;
    newHeight = $("#parentMainGridDiv").height() - 50;

    myGridCtrl.jqGrid('setGridWidth', newWidth, false);
    myGridCtrl.jqGrid('setGridHeight', newHeight);
}

window.setTimeout(patchUpJQGrid_FitInParentDiv, 5000);//ensure jqGrid correctly sized

Thus, after the above script runs, the UI is all set and sized correctly.. but then you begin scrolling (either with mouse wheel or using scroll bar) and eventually the grid width disregards what was initially instructed via 'setGridWidth' and now the parent DIV is essentially masking or eclipsing the vertical scrollbar that you need if you want to continue scrolling..

SOLUTION

See the accepted answer below for more details. I'd like to mention that these add'l options (copied from another Oleg answer) are helping me acheive what I want in my jqGrid instances (see updated jsfiddle demo)

    cmTemplate: { autoResizable: true },
    autoResizing: { compact: true },
    autoresizeOnLoad: true
bkwdesign
  • 1,953
  • 2
  • 28
  • 50
  • I never test with `scroll: 1` option, because I don't like the option. Could you provide the demo, which uses non-minimized version of free jqGrid (`https://rawgit.com/free-jqgrid/jqGrid/master/js/jquery.jqgrid.src.js`) and which can be used to reproduce the problem? It's good to have the same code which use version 4.4.5 to see more clear the difference. – Oleg Jun 24 '16 at 21:32
  • Here's a demo in [jsFiddle](https://jsfiddle.net/bkwdesign/a6jpwecm/) of the problem behavior. Give it a second to load up and resize the grid into a 500 x 500 container. Then, try scrolling it with the scrollbar. – bkwdesign Jun 27 '16 at 17:10
  • Thank you for the demo. It seems that the `gridResize` method has the bug if jqGrid uses virtual scrolling (`scroll: 1`). I'm busy now, but I'm examine the problem and will fix it as soon as possible. I'll inform you after the problem will be fixed. – Oleg Jun 28 '16 at 08:12
  • @Oleg - FWIW - I noticed when playing with the jsFiddle, you can even set the scroll: 0 and the behavior is still exhibited the moment you go to a different page of results. – bkwdesign Jun 28 '16 at 12:12
  • I'm not sure what you mean. The option `height: 'auto'` means that the height of the grid have to be the total sum of rows. The method `gridResize` of free jqGrid allows to resize only the width (not the height) if the `height: "auto"` or `height: "auto"`. You can change the behavior by usage `handle` options of `gridResize` (for example `.jqGrid("gridResize", {handles:"all"})`), but the option `height: 'auto'` and missing `width` are wrong. I posted the previous comment first and wrote my answer one hour later. You should use `width: 450, height: 404` (or any other fixed values). – Oleg Jun 28 '16 at 14:25
  • if you change the `scroll` option to `0` in the jsFiddle demo (or simply remove the scroll option altogether) and then hit "Run >" in the jsFiddle.. then use the pager control to navigate the results, the width will change – bkwdesign Jun 28 '16 at 15:09
  • I'm not sure what you want to prove. The usage of `height: 'auto'` is really **wrong** in your scenario. If you want that `gridResize` resize in both directions you can move call of `gridResize` **after** the `height` is changed (at the end of `patchUpJQGrid_FitInParentDiv`). You will fix the current problem, but you will have other problems later. jqGrid saves the **original** values of `width` in `widthOrg` option and it uses the values in some cases. If you want that the height or width not adjusted automatically then you should create the grid with some **fixed** values. – Oleg Jun 28 '16 at 15:51

1 Answers1

1

Some jqGrid options, which you use in jqGrid are wrong in case of usage scroll: 1. You fixed the problems in old jqGrid by usage patchUpJQGrid_FitInParentDiv. To make the code working in free jqGrid you need just fix the original options of jqGrid.

The main problem in the options is the usage of height: 'auto' and specifying of no width options. It's wrong if you use scroll: 1. One should specify any fixed values for height and width options. You can modify the values later, but the initial values are very important and there modifies the behavior of resizing.

What you need to do is to change the options

    ...
    pager: '#pager1',
    altRows: true,
    altclass: 'myAltRowClass',
    rownumbers: true,
    gridview: true,
    rowNum: 50,
    rowList: [50, 100, 250],
    height: 'auto',
    caption: "Test Queue",
    scrollOffset: 2,
    viewrecords: true,
    sortorder: 'desc',
}

to

    pager: '#pager1',
    altRows: true,
    altclass: 'myAltRowClass',
    rownumbers: true,
    gridview: true,
    //rowNum: 50,
    //rowList: [50, 100, 250],
    //height: 'auto',
    width: 450,
    height: 404,
    caption: "Test Queue",
    //scrollOffset: 2,
    viewrecords: true
    //sortorder: 'desc',
}

After the changes one can remove the call of patchUpJQGrid_FitInParentDiv because it's no more required.

I want to stress that the above changes are strictly recommended event for the old jqGrid versions. The changes are required for free jqGrid.

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Thanks to @Oleg's [other answer on column widths](http://stackoverflow.com/a/32053257/1520850) I was able to update my [jsFiddle demo](https://jsfiddle.net/bkwdesign/a6jpwecm/4/) to load the way I would like (per the 1st screen in my O.P.) – bkwdesign Jul 13 '16 at 04:07