ExtJS 3 网格自动宽度

标签 extjs

在 ExtJS 3 中,如何将网格设置为自动宽度?我已经尝试了下面的代码,它不起作用。

谢谢

var exceptionGrid = new Ext.grid.GridPanel({
    store: exceptionStore,
    loadMask: true,
    frame: true,
    // defaultWidth: 450,
    //height: 560,
    autoHeight: true,
    autoWidth: true,
    colModel: new Ext.grid.ColumnModel({
        defaults: {
            width: 120,
            sortable: true
        },
        columns: [{
            header: 'COL1',
            dataIndex: 'COL1'
        }, {
            header: 'COL2',
            dataIndex: 'COL2'
        }, {
            header: 'COL3',
            dataIndex: 'COL3'
        }, .....]
    }),
    viewConfig: {
        forceFit: false
    }
});

最佳答案

来自 extjs 3 文档:

GridPanel

Notes:

 - Although this class inherits many configuration options from base
   classes, some of them (such as autoScroll, autoWidth, layout, items,
   etc) are not used by this class, and will have no effect.

 - A grid requires a width in which to scroll its columns, and a height
   in which to scroll its rows. These dimensions can either be set
   explicitly through the height and width configuration options or
   implicitly set by using the grid as a child item of a Container which
   will have a layout manager provide the sizing of its child items (for
   example the Container of the Grid may specify layout:'fit').

如果未指定,Grid 的宽度默认采用容器宽度。 Ext.grid.GridPanel#autoExpandColumn 将有助于扩展网格中的一列,占用剩余的水平空间。查看 Ext.grid.GridView 的 forceFitautoFill 调整列宽也很有帮助。

关于ExtJS 3 网格自动宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11369309/

相关文章:

extjs - extjs 中具有不同数据类型的同一商店

android - sencha 包无法在 Release模式下运行 zipalign

javascript - ExtJS、Flask 和 AJAX : cross-domain request

extjs - 加载数据后如何刷新面板?

javascript - 如何在javascript中制作定时队列

extjs - 如何在extjs中实现以下功能

Extjs Accordion 布局

javascript - Extjs Ext.ComboBox 自动调整现有内容的大小

javascript - 从 Extjs 4 中的 form.getValues() 获取空组合字段值

javascript - 如何在表格中找到最后一个可见的 <td>?