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中显示两个字段内容

 

原文出处:http://www.cnblogs.com/jadebug/archive/2011/06/27/2091348.html

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值