网格中的 Extjs4 组合框 displayValue [英] Extjs4 combobox displayValue in grid
本文介绍了网格中的 Extjs4 组合框 displayValue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请帮忙.我想在网格中显示我的 displayValue
.我在此处找到了解决方案,但我无法理解怎么用.我的代码:
Please, help.
I want to show my displayValue
in the Grid.
I found the solution here, but I can't understand how use it. My code:
columns:[...,{
header: 'Product',
id: 'combo',
locked: true,
dataIndex: 'prod_id',
editor: {
xtype: 'combobox',
store: new Ext.data.Store({
fields: ['value','display'],
data: prod_list
}),
displayField: 'display',
valueField: 'value'
}
},...]
解决方案
Ext.util.Format.comboRenderer = function(combo){
return function(value){
var record = combo.findRecord(combo.valueField || combo.displayField, value);
return record ? record.get(combo.displayField) : combo.valueNotFoundText;
}
}
{
header: 'Товар',
id: 'combo',
locked: true,
dataIndex: 'prod_id',
editor: MyEditor,
renderer: Ext.util.Format.comboRenderer(MyEditor)
}
我试图在列数组之外定义编辑器.
I tried to define editor outside of the column array.
var MyEditor = new Ext.form.field.ComboBox({
store: new Ext.data.Store({
fields: ['value','display'],
data: prod_list
}),
displayField: 'display',
valueField: 'value'
});
一切都很好,但我无法编辑.有什么问题?
对不起我的英语.
And all is fine, but I can't edit it. What is the problem?
Sorry for my English.
推荐答案
var myStore = new Ext.data.Store({
fields: ['value','display'],
data: prod_list
});
...
editor: {
xtype: 'combobox',
store: myStore,
displayField: 'display',
valueField: 'value'
},
renderer: function(val){
index = myStore.findExact('value',val);
if (index != -1){
rs = myStore.getAt(index).data;
return rs.display;
}
}
这篇关于网格中的 Extjs4 组合框 displayValue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文