[英]Extjs ComboBox inside grid
我有一个带有一些数据的网格(用户列表)。 对于每一行,我有许多操作,例如更新,删除,激活,暂停,查看您为其命名的订单。
我没有放置那么多可以填充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'
})
}
]
});
- 将网格转换为可编辑网格
- 在列中添加编辑器配置而不是“渲染器”。 在下面找到更改的代码。
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'
}
}]
});
你试图完成这一点大多是正确的。 您添加自定义编辑器的方式可能需要一些调整..您是否尝试过此更改?
editor: new Ext.form.ComboBox({
store: new Ext.data.SimpleStore({
id: 0,
遗憾的是,我无法确定您的代码在做什么而且无法正常工作。
您使用的是什么版本的ExtJS? 有一点值得注意的是,我发现在当前的ExtJS API文档中我没有看到任何名为Ext.data.SimpleStore的对象。 您是否尝试过使用其他类型的数据存储? 您可能想尝试为此组合使用不同类型的商店?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.