English 中文(简体)
jQuery jqGrid支持水平滚动条和冻结列吗?
原标题:Does jQuery jqGrid support horizontal scroll bar and frozen columns?

我有一个jqGrid有很多列,当列宽之和大于固定宽度容器时,它显示为这样:

如果网格的宽度太大,则不要使用水平滚动条。

我如何获得jQgrid的水平滚动条,以便有一个固定的网格最大大小,如果我添加更多的列,它将简单地滚动?

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

最佳回答

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

更新:尝试设置收缩ToFit:false宽度:600(例如)并查看结果。

仅设置<code>shrinkToFit:false</code>后,您可以看到网格将具有水平滚动条。你会看到它,即使网格足够小,可以在没有滚动的情况下显示。这是我发布的一个错误,则计算网格的宽度以及相应的错误修复。该修复包含在GitHub,但未包含在jqGrid 3.8.2中。下一个jqGrid版本将进行修复。然而,出于您的目的,错误的宽度并不重要,因为您将/可以显式设置网格的宽度

问题回答

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>

并运行此脚本:

$( #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.

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

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

祝你好运





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签