Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Extjs自动调整网格列大小以适应现代工具包中的内容_Extjs - Fatal编程技术网

Extjs自动调整网格列大小以适应现代工具包中的内容

Extjs自动调整网格列大小以适应现代工具包中的内容,extjs,Extjs,如何自动调整网格列的大小,使列的宽度达到显示内容所需的宽度 这在Classic中是可能的,但在现代工具包中似乎不可能。看起来这最终在7.0.0中进行了排序,并将autoSize方法添加到Ext.grid.column.column中,使其与Classic保持一致 但是,它在7.0.0到7.3.1中无法正常工作,并且无法将宽度设置为文本的正确大小。在v7.0中实现了典型的低质量方法Ext.grid.column.column.autoSize()。它不适用于flexed列(classic tool

如何自动调整网格列的大小,使列的宽度达到显示内容所需的宽度


这在Classic中是可能的,但在现代工具包中似乎不可能。

看起来这最终在7.0.0中进行了排序,并将autoSize方法添加到Ext.grid.column.column中,使其与Classic保持一致


但是,它在7.0.0到7.3.1中无法正常工作,并且无法将宽度设置为文本的正确大小。在v7.0中实现了典型的低质量方法Ext.grid.column.column.autoSize()。它不适用于flexed列(classic toolkit中的AFAIK是相同的)。请看以下示例:

Ext.application({
    name: 'Fiddle',

    launch: function () {
        var store = Ext.create('Ext.data.Store', {
            fields: ['name', 'email', 'phone'],
            data: [{
                'name': 'Lisa',
                "email": "lisa@simpsons.com",
                "phone": "555-111-1224"
            }, {
                'name': 'Bart',
                "email": "bart@simpsons.com",
                "phone": "555-222-1234"
            }, {
                'name': 'Homer',
                "email": "home@simpsons.com",
                "phone": "555-222-1244"
            }, {
                'name': 'Marge',
                "email": "marge@simpsons.com",
                "phone": "555-222-1254"
            }]
        });

        Ext.create('Ext.Panel', {
            title: 'Simpsons',
            fullscreen: true,
            layout: 'vbox',
            items: [{
                xtype: 'toolbar',
                items: [{
                    xtype: 'button',
                    text: 'Button 1',
                    handler: function(btn) {
                        var grid = this.up('panel').down('grid');
                        grid.getColumns().forEach(function(column) {
                            column.autoSize();
                        })
                    }
                }]
            }, {
                xtype: 'grid',
                height: 200,
                store: store,
                columns: [{
                    text: 'Name',
                    dataIndex: 'name'
                }, {
                    text: 'Email',
                    dataIndex: 'email'
                }, {
                    text: 'Phone',
                    dataIndex: 'phone',
                    flex: 1 // Will not autoSize.
                }]
            }]
        });
    }
});

只是好奇,这在经典中是如何实现的?我在使用autoSize函数:例如myGrid.getColumns()[1]。autoSize()啊,我明白了。。。我想这是一个网格/列的设置,但我假设你在加载数据后调用了这个方法?