jQuery jqGrid 支持水平滚动条和冻结列吗?

发布于 2024-10-16 23:50:31 字数 327 浏览 7 评论 0原文

我有一个 jqGrid 有很多列,它显示了当列宽度总和大于固定宽度容器时,如下所示:

在此处输入图像描述

而不是水平如果网格宽度太大则滚动条。

如何获得 jQgrid 的水平滚动条,以便网格的最大尺寸是固定的,如果我添加更多列,它就会简单地滚动?

另外,假设这是可能的,您可以冻结前几列吗?

I have a jqGrid with a lot of columns, and it shows up like this when the sum of the column widths are bigger than the fixed width container:

enter image description here

Instead of having a horizontal scroll bar if the width of the grid is too big.

How can I get a horizontal scroll bar for jQgrid so there is a fixed max size of the grid and if I add more columns it will simply scroll?

Also, assuming this is possible, can you freeze the first few columns?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

顾铮苏瑾 2024-10-23 23:50:31

可能您使用 forceFit:true jqGrid 选项。首先,您应该设置 forceFit:false 或使用 shr​​inkToFit:false。之后,您可以使用 jqGrid 的 width 选项或使用 setGridWidth 方法设置网格宽度。您将拥有网格,其中列标题对应于列的 width 属性,并且网格将具有水平滚动条。

更新:尝试设置shr​​inkToFit:falsewidth:600(例如)并查看结果。

仅设置 shr​​inkToFit:false 后,您可以看到网格将具有水平滚动条。即使网格足够小,无需滚动即可显示,您也会看到它。这是我发布的一个错误 此处 以及相应的错误修复。该修复包含在 GitHub 上的代码中,但未包含在 jqGrid 3.8 中.2.下一个 jqGrid 版本将修复此问题。尽管如此,对于您的目的而言,错误的宽度并不重要,因为您将/可以显式设置网格的宽度。

Probably you use forceFit:true jqGrid option. First of all you should set forceFit:false or use shrinkToFit:false. After that you can either use width option of jqGrid or use setGridWidth method to set grid width. You will have grid where the column header correspond to the width property of the column and the grid will have horizontal scrollbar.

UPDATED: Try to set shrinkToFit:false and width:600 (for example) and see the results.

After setting only shrinkToFit:false you can see that the grid will have the horizontal scroll bar. You will see it even the grid is small enough to be displayed without the scrolling. It is a bug which I posted here together with the corresponding bug fix. The fix is included in the the code on the GitHub, but not included in the jqGrid 3.8.2. The next jqGrid release will have the fix. Nevertheless for your purpose the wrong width is not important because you will/can set the width of grid explicitly.

怪我太投入 2024-10-23 23:50:31

您可以通过用 div 包装网格和分页器并运行一个小脚本来获得具有静态或自动大小字段的水平滚动条,
你可以看到 jsfiddle-example,或者像这样:

<div id="grid_container">
  <table id="list"></table>
  <div id="pager"></div>
</div>

并运行这个脚本:

$('#grid_container div:not(.ui-jqgrid-titlebar)').width("100%");    

我的例子是使用 trirand.com 的脚本,但 iv 在他们的最新版本上尝试过,效果很好。
希望我有所帮助。

you can get horizontal scroll bar with static or auto size fields by wrapping the grid and pager with a div and run a small script,
you can see the jsfiddle-example, or just go like so:

<div id="grid_container">
  <table id="list"></table>
  <div id="pager"></div>
</div>

and run this script:

$('#grid_container div:not(.ui-jqgrid-titlebar)').width("100%");    

my example is using the script from trirand.com but iv tried it on their newest release and it worked just fine.
hope i've helped.

赠佳期 2024-10-23 23:50:31

尝试使用 fluid jqGrid 插件。也许它可以帮助您解决 jqGrid 宽度的问题。

至于第二个问题,为了冻结前n列,我成功地使用了这个超级插件 用于冻结第一列。您只向 colmodel 添加一个属性,它就可以工作。

祝你好运!

Try to use the fluid jqGrid plugin. Maybe it helps you with your problem with the jqGrid width.

As for the second question, for freezing the first n columns I am successfully using this super plugin for freezing the first columns. You add only one attribute to your colmodel and it works.

Good luck!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文