Ext JS 3自动宽度列网格

时间:2014-11-28 04:21:47

标签: javascript extjs

对不起, 如何在Ext JS 3的网格列中设置自动宽度? 到目前为止,这是我的代码:

<script type="text/javascript">
            Ext.onReady(function () {
                var mystore = new Ext.data.Store({proxy: new Ext.data.HttpProxy({url: 'info-extjs.php'}),
                    reader: new Ext.data.JsonReader({
                        root: 'guests',
                        fields: [{name: 'ip_address'},
                            {name: 'country'},
                            {name: 'region'},
                            {name: 'comp_name'},
                            {name: 'page'},
                            {name: 'timestamp'}]
                    })
                });
                //create the grid     
                var grid = new Ext.grid.GridPanel({
                    store: mystore,
                    title: 'Guest List of our blog',
                    columns: [{
                            id: 'ip_address',
                            header: 'IP Address',
                            autoSizeColumn: true, 
                            minWidth: 120,
                            sortable: true,
                            dataIndex: 'ip_address'
                        },
                        {
                            id: 'country',
                            header: 'Country',
                            autoSizeColumn: true, 
                            minWidth: 120,
                            sortable: true,
                            dataIndex: 'country'
                        },
                        {
                            header: 'region',
                            autoSizeColumn: true, 
                            minWidth: 120,
                            sortable: true,
                            dataIndex: 'region'
                        },
                        {
                            header: 'comp_name',
                            autoSizeColumn: true, 
                            minWidth: 120,
                            sortable: true,
                            dataIndex: 'comp_name'
                        },
                        {
                            header: 'page',
                            sortable: true,
                            dataIndex: 'page',
                            autoSizeColumn: true, 
                            minWidth: 150
                        },
                        {
                            header: 'timestamp',
                            sortable: true,
                            dataIndex: 'timestamp',
                            autoSizeColumn: true, 
                            minWidth: 150
                        }],
                    renderTo: 'guest-list-grid',

                    autoHeight: true
                });
                mystore.load();
            });
        </script>    

我尝试使用:

autoSizeColumn: true, 
minWidth: 150

但不幸的是,它无法运作。这是图片: result 请帮忙。 Ext Js版本: EXT-3.4.0

1 个答案:

答案 0 :(得分:0)

尝试将forceFit: true添加到网格的viewconfig

...
renderTo: 'guest-list-grid',    
viewConfig: {
    forceFit: true
},
相关问题