您链接到的另一个 SO 问题与 Ext 的先前版本有关,而不是 Ext 4。flex 选项确实是您正在寻找的...您不限于用整数设置它, 和 flexed 列的宽度将遵循它们的 flex 值之间的比率。
此外,您可以通过使用 100 的分数来明确传达百分比的概念。
这是一个例子:
Ext.create('Ext.grid.Panel', {
title: "Resize me!",
// Ratios will be kept when the grid is resized.
resizable: true,
columns: {
// If you want to guarantee that your columns will keep
// the given ratios, you must prevent the user from
// resizing them.
defaults: {
resizable: false
},
items: [{
text: 'Name',
dataIndex: 'name',
flex: 25 / 100
}, {
text: 'Email',
dataIndex: 'email',
flex: 25 / 100
}, {
text: 'Phone',
dataIndex: 'phone',
flex: 50 / 100
}]
},
height: 200,
width: 400,
renderTo: Ext.getBody(),
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"
}]
}
});