我有一些带有一些数据的网格(用户列表)。对于每一行,我都有许多操作,例如更新,删除,激活,暂停,查看您为其命名的订单。
我希望放置一个组合框,并将动作应用于每个字段,而不是放置太多会填充400-500
像素的按钮。
问题是我不能简单地在列行中渲染一个组合框,或者我错过了什么?有人可以对此有所了解吗?
new Ext.grid.GridPanel({
region: 'center',
id: 'usersGrid',
store: store,
stripeRows: true,
autoExpandColumn: 'username',
columns: [{
// username
},{
// email
},{
// last seen
},{
// actions combo, it won't show
header: '',
width: 220,
fixed: true,
hideable: false,
dataIndex: 'actions',
renderer: new Ext.form.ComboBox({
store: new Ext.data.SimpleStore({
id: 0,
fields: ['abbr', 'action'],
data: [
['suspend', 'Suspend'],
['activate', 'Activate'],
['update', 'Update'],
['delete', 'Delete']
]
}),
displayField: 'action',
valueField: 'abbr',
mode: 'local',
typeAhead: false,
triggerAction: 'all',
lazyRender: true,
emptyText: 'Select action'
})
}
]
});
答案 0 :(得分:9)
- 将网格转换为可编辑网格
- 在列中添加编辑器配置而不是“渲染器”。在下面找到更改后的代码。
醇>
new Ext.grid.EditorGridPanel({
region: 'center',
id: 'usersGrid',
store: store,
stripeRows: true,
autoExpandColumn: 'username',
columns: [{
// username
}, {
// email
}, {
// last seen
}, {
// actions combo, it won't show
header: '',
width: 220,
fixed: true,
hideable: false,
dataIndex: 'actions',
editor: {
xtype: 'combo',
store: new Ext.data.ArrayStore({
fields: ['abbr', 'action'],
data: [
['suspend', 'Suspend'],
['activate', 'Activate'],
['update', 'Update'],
['delete', 'Delete']
]
}),
displayField: 'action',
valueField: 'abbr',
mode: 'local',
typeAhead: false,
triggerAction: 'all',
lazyRender: true,
emptyText: 'Select action'
}
}]
});
答案 1 :(得分:0)
你试图完成这一点大多是正确的。您添加自定义编辑器的方式可能需要一些调整..您是否尝试过此更改?
editor: new Ext.form.ComboBox({
store: new Ext.data.SimpleStore({
id: 0,
我很遗憾无法确定您的代码在做什么而且无法正常工作。
您使用的是什么版本的ExtJS?有一点值得注意的是,我发现在当前的ExtJS API文档中我没有看到任何名为Ext.data.SimpleStore的对象。您是否尝试过使用其他类型的数据存储?您可能想尝试为此组合使用不同类型的商店吗?