2011-05-05 256 views

回答

29

我会建议您设置"max-height"财产上的jqGrid的bdiv和使用height:'100%'height:'auto'

$("#list").parents('div.ui-jqgrid-bdiv').css("max-height","300px"); 

"max-height"属性将是not used by IE6,但最近的Web浏览器会用它。

已更新:免费jqGrid在版本4.10.0中引入了新属性:maxHeight,其功能与上述完全相同。因此,人们可以使用maxHeight: 300而不是手动设置父母div.ui-jqgrid-bdivmax-height。您想要的网页上加载的jqGrid后

var height = $(window).height(); 
$('.ui-jqgrid-bdiv').height(height); 

,这个工作对我来说:

+0

试过上述建议,但它仍然没有工作...也... ...我需要一个解决方案,将工作在IE6太。 – Dieter 2011-05-05 11:35:21

+0

您在哪个网页浏览器中测试过,并且无法正常工作?我建议你**不支持IE6 **如果可能的话。我的意思是在IE6中显示网格很好(但不完美),因为它会忽略CSS属性。如果你需要设置IE6的高度,那么你将不得不在'loadComplete'中设置网格**高度**。你可以使用'getGridHeight'和'setGridHeight'方法。 – Oleg 2011-05-05 11:57:28

+0

没有像getGridHeight这样的东西...我想你的意思是getGridParam(“高度”)...但与loadComplete或gridComplete结合使用它不会返回像素高度;相反,它返回“自动”...并回答首先提出的问题:)我在IE9中测试它... – Dieter 2011-05-05 13:59:16

0

添加此。

12

试试这个

jQuery("#yourid").jqGrid({ 
    ........ 
    height:'auto' 
}); 
+0

伟大的解决方案... :) – 2014-04-15 06:21:34

0

尝试这些方法

1.定义网格

     $("#griname").jqGrid(
           { 
            rowNum : 1000, 
            viewrecords : true, 
            gridview : true, 
            autoencode : true, 
            loadonce : true, 
            width: "100%", 
            height: 300, 
          }); 

2,本功能可用于保持内部的高度高度固定为预定义的值。

$(window).resize(function() { 

if (typeof($gridname) !== 'undefined' && $("#gridname").length > 0) { 
    $discrepanciesResultGrid.setGridHeight(
     $(window).height() - $("#gridname").position().top - 210 
    ); 
    $gridname.setGridWidth($("body").width() - $("#anothercomponenetname").width() - 50); 
    } 
0

试试这个

$("#list1").parents(".ui-jqgrid-bdiv").css('height', jQuery("#list1").css('height')); 

此代码将根据中行的网格数调整电网的高度

0

我们的UI人解决了这个问题(展开列表最多300px,如果有超过10个附件,显示一个垂直滚动条)用css

#gview_list_Attachments .ui-jqgrid-bdiv{ 
    max-height: 300px; 
    overflow-y: visible; 
} 

300px在我们的案例中恰好是10个项目的高度。当然,使用jQuery你可以确定1个项目的高度并乘以10.但是这个解决方案很快,简单并且解决了我们的问题。

1
.ui-jqgrid-view { 
    max-height: 642px; 
} 
.ui-jqgrid-bdiv { 
    overflow-y: scroll !important; 
    max-height: 600px !important; 
} 

这个工作对我的jqGrid