jqGrid水平滚动条
我使用 jQuery 和 jqGrid 开发了 AJAX 界面。
如何从 jqGrid 表中删除水平滚动条?
http://dskarataev.ru/jqgrid.png
如果我设置 autowidth: true
,然后我得到表的宽度=列的总宽度,但是我需要表的宽度=父元素的宽度,其id由函数getSelectedTabHref()
返回,
所以我创建了函数:
$(window).bind('resize', function() {
$('#tasks').setGridWidth($(getSelectedTabHref()).width());
$('#tasks').setGridHeight($(window).height()-190);
}).trigger('resize');
这是我的方法创建jqGrid表:
$('#tasks').jqGrid({
datatype: 'local',
colNames:[labels['tasksNum'],labels['tasksAdded']+"/"+labels['tasksAccepted'],labels['tasksOperator'],labels['tasksClient'],labels['tasksManager'],labels['tasksDesc']],
colModel :[
{name:'taskId', index:'taskId', width:1, align:'right'},
{name:'taskAdded', index:'taskAdded', width:3},
{name:'taskOperator', index:'taskOperator', width:4},
{name:'taskClient', index:'taskClient', width:7},
{name:'taskManager', index:'taskManager', width:4},
{name:'taskDesc', index:'taskDesc', width:8}]
});
I developed AJAX interface with jQuery and jqGrid.
How I can remove horizontal scrollbar from my jqGrid table?
http://dskarataev.ru/jqgrid.png
If I set autowidth: true
, then I get width of table = sum width of columns, but I need width of table = width of parent element with id returned by function getSelectedTabHref()
so I make function:
$(window).bind('resize', function() {
$('#tasks').setGridWidth($(getSelectedTabHref()).width());
$('#tasks').setGridHeight($(window).height()-190);
}).trigger('resize');
and here is how I create jqGrid table:
$('#tasks').jqGrid({
datatype: 'local',
colNames:[labels['tasksNum'],labels['tasksAdded']+"/"+labels['tasksAccepted'],labels['tasksOperator'],labels['tasksClient'],labels['tasksManager'],labels['tasksDesc']],
colModel :[
{name:'taskId', index:'taskId', width:1, align:'right'},
{name:'taskAdded', index:'taskAdded', width:3},
{name:'taskOperator', index:'taskOperator', width:4},
{name:'taskClient', index:'taskClient', width:7},
{name:'taskManager', index:'taskManager', width:4},
{name:'taskDesc', index:'taskDesc', width:8}]
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(13)
我调整了 ui.grid.css 因为我根本不需要水平滚动条。我这样做了:
评论是这样的,我只是使用overflow-x来隐藏水平滚动条,现在一切都对我来说很好。
i adjusted ui.grid.css because i did not need a horizontal scrollbar at all. i did this:
the commented was how it was, i just used overflow-x to hide the horizontal scrollbar and now all is fine with me.
在某些情况下,jqGrid 计算网格宽度不正确。您可以尝试增加
cellLayout
参数(参见 http://www.trirand.com/jqgridwiki/doku.php?id=wiki:options)。如果您从 jqGrid 更改一些 CSS,则可能需要这样做。在其他一些情况下,您可以使用我在 在 jQueryUI 对话框内的 jqGrid 上正确调用 setGridWidth。不要忘记,您应该在
loadComplete
内部使用它。There are some situations where jqGrid calculate the grid width incorrect. You can try to increase
cellLayout
parameter (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:options). This may be needed if you change some CSS from jqGrid.In some other situations you can correct the width with respect of the function
fixGridWidth
orfixGridSize
which I have described in Correctly calling setGridWidth on a jqGrid inside a jQueryUI Dialog. Don't forget, that you should use it inside ofloadComplete
.在网格上设置显式
宽度
并使用Set an explicit
width
on the grid and usesetGridWidth 肯定会将网格大小调整为给定的新宽度,但请确保将其与 autowidth=true 一起使用。 setGridWidth 在 IE 7 左右可能有问题。
这里讨论了一些可行的解决方案(如果您还没有找到解决方案),
调整 jqGrid 的大小当浏览器调整大小时?
http://www.trirand.com/blog/?page_id=393/discussion/browser-resize-how-to-resize-jqgrid/
----老----
有几个您可以尝试的选项,
来自 http://www.trirand.com /jqgridwiki/doku.php?id=wiki:options
或
否则发布你的 jqgrid 代码,让我们分析。
setGridWidth will definitely resize your grid to that of the given new width, but make sure you use it with autowidth=true. setGridWidth may have problem with IE 7 or so.
Some working solutions discussed here (in case if you are yet to find a solution),
Resize jqGrid when browser is resized?
http://www.trirand.com/blog/?page_id=393/discussion/browser-resize-how-to-resize-jqgrid/
----old----
There are couple of options you can try,
From http://www.trirand.com/jqgridwiki/doku.php?id=wiki:options
or
Otherwise post your jqgrid code, let us analyze.
有点晚了,但可能对某人有用
您必须仅以数字设置表格的高度,末尾不带“px”
a bit late, but might be useful for someone
You must set the height of the table only in numbers, without 'px' at the end
在这里,
width:'1083'
,shrinkToFit:false,
当我们设置上述内容时,我们需要确保我们的
ui.jqgird.css
设置如下Here we go
width : '1083'
,shrinkToFit:false,
When we set the above we need to make sure that our
ui.jqgird.css
are set as below很简单,在jqgrid中使用
shrinkToFit: false
Its simple, use in the jqgrid
shrinkToFit: false
将以下脚本添加到您的 style.css 将解决您的问题。
Add the below script to your style.css will resolve your issue.
这对我有用
This works for me
我使用jqgrid API方法setGridHeight。它在 IE 8 中也适用于我。
我将此行放在“loadComplete”函数调用下。
i used jqgrid API method setGridHeight. it works fine for me in IE 8 also.
i put this lines under 'loadComplete' function call.
将 AppearanceSettings
ShrinkToFit="False"
和AutoWidth="true"
应用于您的jqGrid
。Apply AppearanceSettings
ShrinkToFit="False"
andAutoWidth="true"
to yourjqGrid
.这就是我的做法,到目前为止,效果很好。基本上,我们调整网格大小以适应垂直滚动条,并且通过调整大小,不会出现水平溢出,因此水平滚动条永远不会显示。我们的单元格大小保持不变,并且最后一个单元格没有部分隐藏。
Here is how I did it and so far, so good. Basically, we resize the grid to accommodate the vertical scroll bar and by resizing, there is no horizontal overflow and therefore, the horizontal bar never shows up. Our cell sizing remains the same and the last cell is not partially hidden.
我在 jqgrid 中调整这种类型的 CSS
I adjust this type of CSS in my jqgrid