How to remove free jqgrid own horizontal scrollbar if autowidth:true is used

妖精的绣舞 提交于 2019-12-02 05:03:01

I agree that the calculation of the width of the grid is not perfect in case of usage of autowidth: true. Nevertheless the problem which you describe is not a jqGrid problem. It's good that you included outer div over the grid in the demo which you posted. It shows the complexity of the problem.

First of all it will be displayed no horizontal scroll bar in IE10/IE11 in the demo which you posted. The reason is that IE displays half transparent vertical scrollbar by default. So it's not creates additional horizontal scroll bar in the case which you described.

You can fix the problem by adding the following lines at the end of your demo:

if (window.innerWidth > document.documentElement.clientWidth) {
    $grid.jqGrid("setGridWidth",
        $grid.jqGrid("getGridParam", "width") -
        (window.innerWidth - document.documentElement.clientWidth));
}

See the results here.

On the other side the demo have outer div over the grid with margin:5px. If I change the margin:5px to margin:200px then the same demo will looks as the following. One can increase the width of the grid to almost 200 additional pixel (the exact maximum is 200 - 4, which I can't explain now, but the value can be changed after I improve the code of setGridWidth). See the next demo. The reason: the outer div have both margin-left and margin-right set to 200px, but the scroll bar on the page will not exist if we would ignore the margin-right. It's only the margin and there are exist no real elements on the page in the space. Thus the web browsers don't creates horizontal scroll bars in the case.

Add this style to you code

<style type="text/css">
   .ui-jqgrid-bdiv {
       overflow-x: hidden !important;
   }
</style>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!