extjs 3.4可编辑网格:如何在列中分离displayField和ValueField
我正在尝试制作看起来像这样的东西: http://dev.sencha.com/deploy/ext-3.4.0/examples/grid/edit-grid.html
但我想更改 Light 列:
我希望它包含 ids 而不是实际值。
我可以强制组合框将值与表示形式分离,但不能分离实际的列值(事实上,我不知道在哪里存储列的 id-value 映射(不仅仅是编辑器)):
new Ext.grid.EditorGridPanel({
...
store: new Ext.data.Store ({
...
fields: [
'MagicId',
...
]
})
columns: [
{
header: 'Magic',
dataIndex: 'MagicId',
editor: new Ext.form.ComboBox({
store: new Ext.data.Store({
...
fields: ['id', 'title']}),
valueField: 'id',
displayField: 'title',
editable: 'false'
})
},
...
]
当我在组合框中选择“Magic title”时无论如何,我在我的网格中得到了 MagicId。我明白为什么会发生这种情况,但无法让它按照我需要的方式工作...
我尝试用...替换所有不必要的代码以帮助您阅读。
感谢您的关注。
I'm trying to make something that looks like: http://dev.sencha.com/deploy/ext-3.4.0/examples/grid/edit-grid.html
But I want to change Light column:
I want it to contain ids instead of actual values.
I can force combobox to separate values from presentation but not the actual column value (in fact I don't know where to store id-value mapping for column (not just for the editor)):
new Ext.grid.EditorGridPanel({
...
store: new Ext.data.Store ({
...
fields: [
'MagicId',
...
]
})
columns: [
{
header: 'Magic',
dataIndex: 'MagicId',
editor: new Ext.form.ComboBox({
store: new Ext.data.Store({
...
fields: ['id', 'title']}),
valueField: 'id',
displayField: 'title',
editable: 'false'
})
},
...
]
When I select "Magic title" in combobox I get MagicId in my grid anyway. I understand why it's happening but can't make it work the way I need it to work...
I tried to replace all unnecessary code with ... to help you reading.
Thank you for your attention.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将 ID 字段保留在网格/存储中,然后使用“渲染器”属性来显示其他内容。 ID-文本映射可以存储在数组或对象中:
编辑:
由于您已经在组合存储中拥有 ID 值映射,因此我将使用该存储来获取值(需要在组合框外部声明)。
Keep the ID field in your grid/store, then use the "renderer" property to display something else. ID-text mapping could be stored in an array or an object:
EDIT:
Since you already have the ID-value mapping in the combo store, I would use that store to fetch the value (it needs to be declared outside the combobox).