Extjs 3.3.1 FieldSet 中带有布局适合和网格,不会在调整窗口大小时调整网格大小

Extjs 3.3.1 FieldSet with layout fit and grid in it does not resize the grid on window resize

本文关键字:网格 调整 窗口 小时 FieldSet 布局 Extjs      更新时间:2023-09-26
var colModel = new Ext.grid.ColumnModel({
      columns: [ columns here...]
})
var grid = new Ext.Ext.grid.GridPanel({
   store: store,
   loadMask: true,
   autoExpandColumn: 'itemDescription',
   stripeRows: true,
   colModel: colModel
})
var form = new Ext.FormPanel({
   labelWidth: 150,
   bodyStyle: 'padding:2px 5px;',
   autoScroll: true,
   items:[
     new Ext.form.FieldSet({
       layout: 'fit',
       collapsible: true,
       height:300,
       items: [
            grid 
       ]
     }
   ]
})

调整窗口大小后,网格不会更改其宽度...有什么想法吗???

由于layout: 'fit',您的Grid将根据FieldSet调整大小。由于FormPanel没有布局集,因此它会自动使用 layout: 'form' .FieldSet将充当正常Form Field,因此需要配置为自行调整其大小。这可以使用FormLayoutanchor 属性来完成:

var form = new Ext.FormPanel({
    labelWidth: 150,
    bodyStyle: 'padding:2px 5px;',
    autoScroll: true,
    items:[
        new Ext.form.FieldSet({
            layout: 'fit',
            anchor: '-0',
            collapsible: true,
            height:300,
            items: [
                grid 
            ]
        }
    ]
});

这将告诉FieldSet始终保持距离FormPanel右边缘 0 像素。

试试这个.....

var colModel = new Ext.grid.ColumnModel({
  columns: [ columns here...]
})
var grid = new Ext.Ext.grid.GridPanel({
store: store,
loadMask: true, 
autoExpandColumn: 'itemDescription',
stripeRows: true,
colModel: colModel
})
var form = new Ext.FormPanel({
labelWidth: 150,
bodyStyle: 'padding:2px 5px;',
autoScroll: true,
items : {
   xtype : 'fieldset',
   title : 'Give proper Title',
   defaults: {
      anchor: '100%'
   },
   layout: 'anchor',
   collapsible: true,
   items: grid
}
});