2016-08-22 160 views
0

我最近開始在我正在開發的應用程序中使用JQGrid。不過,我在調整窗口大小時遇到​​一些問題。JQGrid調整大小問題

JQGrid放置在設置爲其父容器的25%的表列中。當我展開窗口時,JQGrid正確展開,但是當我縮小窗口時,它不會按比例縮小到父容器,即JQGrid超過父容器的25%。

如果有人可以給我一些關於爲什麼發生這種情況的輸入?

這裏是我的代碼:

<div id="main_body"> 
      <div class="row"> 
       <div id="criteriacolumn" class="column"> 
        <table id="list"></table> 
       </div> 
       <div class="column"> 
       </div> 
      </div> 
    </div> 

的CSS:

 #main_body{ 
    border: 1px solid black; 
    display: table; 
    width: 100%; 
    } 

    .row{ 
    display: table-row; 
    } 

    .column{ 
    display: table-cell; 
    } 

    #criteriacolumn{ 
    border:1px solid red; 
    width: 50%; 
    min-width: 200px; 
    } 

的JS:

$("#list").jqGrid({ 
    url: "http://localhost:8080/Customer/rest/customers/cust", 
    datatype: "json", 
    mtype: "GET", 
    colNames: ["ID", "CU#","Name"], 
    colModel: [ 
     { name: "custId"}, 
     { name: "custNbr" }, 
     { name: "rptName", align: "right" }, 
    ], 
    rowNum:300, 
    autowidth:true 
    scrollOffset:false 
    }); 

回答

0

使用setGridWidth屬性重置基於父控件寬度的網格大小。在窗口大小調整事件中執行此操作。

$(window).resize(function() { 
    var gridWidth = $('#criteriacolumn').width(); 
    if (gridWidth > 0) { 
     $("#list").setGridWidth(gridWidth);    
    } 
});