2011-05-05 87 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