Extjs Combobox中显示两个字段内容
字段1 字段2 字段3
cnbj 中国 北京
cnsh 中国 上海
mgny 美国 纽约
在 combobox中如果想显示字段2+字段3的内容
使用convet
先定义个函数
function seltext(v, record) {
return record.字段2+ record.字段3;
}
然后在store的reader中加入covert,如下:
var comboxStore = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: "getArea.aspx",
method: 'GET'
}),
reader: new Ext.data.JsonReader({
root: 'data',
totalProperty: 'totalCount',
id: 'id',
fields: [{ name: 'id', mapping: '字段1' },
{ name: 'selecttext', convert: seltext}]//这里
})
});最后就可以在combobox中将displayField属性设置为seltext
xtype: 'combo',
fieldLabel: '区域',
store: comboxStore,
mode: 'remote',
displayField: 'selecttext',//这里
triggerAction: 'all',
name: 'area',
emptyText: '请选择区域…',
editable: false,
anchor: '95%'
至此就可以在combobox中显示两个字段内容
浙公网安备 33010602011771号