1

要件は、グリッドの内容が切り捨てられてはならないということです。グリッド全体は、データの幅に合わせてサイズを調整する必要があり、ウィンドウに水平スクロール バーが必要になる場合があります。

これは可能ですか?

Ext JS 4.2

4

1 に答える 1

2

これが私の最終的な解決策でした:

Ext.define('App.view.patient.MyPanel', {
    autoScroll : true,
    columnLines : true,
    extend : 'App.grid.Panel',
    width : 500,
    height : 500,
    store : 'App.store.MyPanel',

    initComponent : function() {

        // [...]

        // After store data is loaded, resize columns to fit contents
        var store = Ext.data.StoreManager.lookup(me.store);
        store.on('load', function(store, records, options) {
            Ext.each(me.columns, function(column) {

                // Resize to contents and get new width
                column.autoSize();
                var width = column.getWidth();

                // The autoSize doesn't take config option "columnLines: true"
                // into consideration so buffer it. Bug described here:
                // http://www.sencha.com/forum/showthread.php?264068
                width = width + 3;

                // No need to go too crazy
                width = Math.min(width, 400);

                column.setWidth(width);
            });
        });

        me.callParent(arguments);
    }
});
于 2013-12-10T18:27:34.327 に答える