3

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
    }
});
4

2 に答える 2

3

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').

グリッドの幅は、指定されていない場合、デフォルトでコンテナの幅になります。Ext.grid.GridPanel#autoExpandColumnは、残りの水平方向のスペースを使用して、グリッド内の1つの列を拡張するのに役立ちます。また、Ext.grid.GridViewのforceFitおよびautoFillが列の幅を調整するのを確認するのに役立ちます。

于 2012-07-07T00:27:08.577 に答える