views:

153

answers:

2

Is there a way to not display the scrollbars? We'd like to also NOT show the extra space where the scrollbars would go if our data didn't fit on the grid.

A: 

You can set the height & weight to 100%, and then the scrollbars won't appear. (They only appear if the grid is larger than the space allocated.) To remove the extra space for the bars, set the scrollOffset to 0.

Here's an example grid definition (corrected version below):

$("#myGrid").jqGrid({
        url: 'datasourceurl',
        datatype: "json",
        colNames: eval(json.colNames),
        colModel: eval(json.colModel),
        rowNum: -1,
        width: 100%,
        height: 100%,
        scrollOffset: 0,
        rowList: [10, 20, 30],
        pager: jQuery('#myPager'),
        ...
    }, 

I haven't tested this, but I use height: 100% for the same purpose... so let me know if you see anything missing.

EDIT: A better definition, and improvement on my json usage - thank you Oleg :)

$("#myGrid").jqGrid({
        url: 'datasourceurl',
        datatype: "json",
        colNames: JSON.parse(json.colNames),
        colModel: JSON.parse(json.colModel),
        width: '100%',
        height: '100%',
        rowList: [10, 20, 30],
        pager: jQuery('#myPager'),
        ...
    }, 
Adam
In general the suggestion to use 100% width and height is absolutely correct. The values must be quoted ('100%' or "100%"). `eval` is evil. If you need it somewhere you should use `JSON.parse`. It is much faster on all current browsers (see http://www.json.org/js.html) and safe of cause. The usage of `rowNum: -1` is also dangerous. It's depend of the server which you use. Much saver either to use a value from the values `rowList` or a large integer like 10000. The usage of `scrollOffset:0` seems me also not needed. Sorry for so much critic, but I have to write this.
Oleg
Thanks for the feedback!
Adam
A: 

It seems this can be done with scrollOffset:0. Saw this tip here

Marcus
Sorry Marcus, but I don't understand how the setting of `scrollOffset:0` can helps if you will have no scroll bars **without the setting** also. Try to play with a test page http://www.ok-soft-gmbh.com/jqGrid/ClientsideEditing6.htm which has no `scrollOffset:0`. It use only `width: '100%'` and `height: '100%'`. Could you find an example where you will do see scroll bars?
Oleg
If I have no scrollbars there is still a space to the right of the grid where the scrollbar would go if there was add'l data. Setting scrollOffset seems to remove this extra space.
Marcus
@Markus: Sorry Markus, but I can only repeat that in my opinion the value of `scrollOffset` parameter is absolutely unimportant at lest together with the settings `width: '100%'` and `height: '100%'` which switch off the scrolling in the jqGrid. Just compare http://www.ok-soft-gmbh.com/jqGrid/ClientsideEditing7.htm having `scrollOffset:500` with http://www.ok-soft-gmbh.com/jqGrid/ClientsideEditing6.htm having default value of `scrollOffset`. Do you can see any differences? I can't.
Oleg