jQuery jqGrid 支持水平滚动条和冻结列吗?
我有一个 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:
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
可能您使用
forceFit:true
jqGrid 选项。首先,您应该设置forceFit:false
或使用shrinkToFit:false
。之后,您可以使用 jqGrid 的width
选项或使用 setGridWidth 方法设置网格宽度。您将拥有网格,其中列标题对应于列的width
属性,并且网格将具有水平滚动条。更新:尝试设置
shrinkToFit:false
和width:600
(例如)并查看结果。仅设置
shrinkToFit:false
后,您可以看到网格将具有水平滚动条。即使网格足够小,无需滚动即可显示,您也会看到它。这是我发布的一个错误 此处 以及相应的错误修复。该修复包含在 GitHub 上的代码中,但未包含在 jqGrid 3.8 中.2.下一个 jqGrid 版本将修复此问题。尽管如此,对于您的目的而言,错误的宽度并不重要,因为您将/可以显式设置网格的宽度。Probably you use
forceFit:true
jqGrid option. First of all you should setforceFit:false
or useshrinkToFit:false
. After that you can either usewidth
option of jqGrid or use setGridWidth method to set grid width. You will have grid where the column header correspond to thewidth
property of the column and the grid will have horizontal scrollbar.UPDATED: Try to set
shrinkToFit:false
andwidth: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 thewidth
of grid explicitly.您可以通过用 div 包装网格和分页器并运行一个小脚本来获得具有静态或自动大小字段的水平滚动条,
你可以看到 jsfiddle-example,或者像这样:
并运行这个脚本:
我的例子是使用 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:
and run this script:
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.
尝试使用 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!