本文介绍了Extjs4组合框中的displayValue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请帮忙。
我想在网格中显示我的 displayValue
。
我在找到了解决方案,但我不明白如何使用它。我的代码:
列:[...,{
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'
}
},...]
h2>
Ext.util.Format.comboRenderer = function(combo){
return function(value){
var record = combo.findRecord(combo.valueField || combo.displayField,value);
返回记录? record.get(combo.displayField):combo.valueNotFoundText;
}
}
{
header:'Товар',
id:'combo',
locked:true,
dataIndex:'prod_id',
编辑器:MyEditor,
renderer:Ext.util.Format.comboRenderer(MyEditor)
}
$ p $ p>
var MyEditor = new Ext.form.field.ComboBox({
store:new Ext.data.Store({
fields:['value','display'],
data:prod_list
}),
displayField:'display',
valueField:'value'
});
一切正常,但我无法编辑。问题是什么?
对我的英语很抱歉。
解决方案 var myStore = new Ext.data.Store({
fields:['value','display'],
data:prod_list
});
...
编辑器:{
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;
}
}
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'
}
},...]
Solution
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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
Ext.util.Format.comboRenderer = function(combo){
return function(value){
var record = combo.findRecord(combo.valueField || combo.displayField,value);
返回记录? record.get(combo.displayField):combo.valueNotFoundText;
}
}
{
header:'Товар',
id:'combo',
locked:true,
dataIndex:'prod_id',
编辑器:MyEditor,
renderer:Ext.util.Format.comboRenderer(MyEditor)
}
$ p $ p>
var MyEditor = new Ext.form.field.ComboBox({
store:new Ext.data.Store({
fields:['value','display'],
data:prod_list
}),
displayField:'display',
valueField:'value'
});
一切正常,但我无法编辑。问题是什么?
对我的英语很抱歉。
解决方案
var myStore = new Ext.data.Store({
fields:['value','display'],
data:prod_list
});
...
编辑器:{
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;
}
}
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'
}
},...]
Solution
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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!