2010-02-23 71 views
1

如何根據窗口大小調整網格面板大小。我已經給出了 viewconfig { forcefit:true }但在Internet Explorer中,網格面板不會縮放帶有窗口大小的 。網格調整大小問題

請幫我在這個問題:

var grid = new Ext.grid.GridPanel({ 
    store : store, 
    colModel : colModel, 
    view  : gv, 
    stateId : 'myGridid',    
    stateful : true,  
    plugins : [filters],   
    autoHeight : true,    
    stripeRows : true,   
    id   : 'my-grid', 
    title  : xppo.st('SDE_PRINTERS'),   
    viewConfig : { forceFit: true },   
    tbar  : tb, 
    listeners: { 
    cellclick: function(grid, rowIndex, colIndex, e) { 
     colClicked = colIndex; 
     if (colClicked != 0) { 
     if (grid.getColumnModel().getDataIndex(grid.getColumnModel().getColumnId(colIndex)) == 'Incident') { 
      return; } 
     } 

     if (colClicked != 0) { 
     var record = grid.getStore().getAt(rowIndex); 
     var paramInScope = record.get("InScope"); 
     var paramAssetID = record.get("AssetID"); 

     if (paramInScope == 'Yes') { 
      OpenPrinterDetailsPopup(paramAssetID, 800, 600); 
     } else { 
      OpenPrinterDetailsPopup(paramAssetID, 300, 200); 
     } 
     } 

    } 
    , rowdblclick: function(grid, rowIndex, columnIndex, e) { 
     if (colClicked != 0) { 
     var record = grid.getStore().getAt(rowIndex); 
     var paramInScope = record.get("InScope"); 
     var paramAssetID = record.get("AssetID"); 

     if (record == null) { return; } 
     if (paramInScope == 'Yes') { 
      OpenPrinterDetailsPopup(paramAssetID, 800, 600); 
     } else { OpenPrinterDetailsPopup(paramAssetID, 300, 200); } 
     } 
    } 
    , expandedFilter: function() { Ext.getCmp('my-grid').setWidth(860); } 
    , collapsedFilter: function() { Ext.getCmp('my-grid').setWidth(1060); } 
    } 
}); 

var userHidden = false; 
if (showColumn) { grid.getColumnModel().setHidden(23, false); } 
else { grid.getColumnModel().setHidden(23, true); } 

if (fl1) { grid.getColumnModel().setHidden(3, fl1); } 
else { grid.getColumnModel().setHidden(3, flags1); } 

grid.getStore().reload(); 
grid.render('grid-example'); 

}); 

回答

0

的forcefit:真位只有當電網是另一個容器內適用,我相信。

如果你只是有一個自由浮動網格,它不是由Ext佈局管理器管理,我認爲你需要指定一個大小。

最簡單的修復方法可能是在網格上方指定一個ViewPort或邊界佈局,然後指定forceFit選項。

1

如果您希望任何組件佔據整個瀏覽器窗口並使用它調整大小,請使用Viewport並將佈局設置爲fit

Ext.onReady(function(){ 
    // ...your grid code... 
    //grid.render('grid-example'); <- do not render the grid, the viewport will do this for you 
    var viewport = new Ext.Viewport({ 
    layout: 'fit', 
    items: [grid] 
    }); 
}); 

請注意,您的標記現在應該<body></body>,因爲Viewport將管理的瀏覽器身上。

+0

我已經爲網格指定了視口,並且評論了網格grid.render,但網格不顯示在網頁上。我的代碼在ascx頁面,我已經在腳本標記中給出了javascript。你已經提到了標記的身體標記,我可以得到那部分。可以請你解釋我。 – xrx215 2010-02-24 18:39:54

+0

這裏是一個最小的Ext JS Viewport完整的HTML頁面,你可以在你的網格中使用:http://gist.github.com/313826 – 2010-02-24 20:44:25

+0

謝謝 我會看看它並嘗試解決它。 – xrx215 2010-02-25 16:09:37