Extjs Combobox中显示两个字段内容

字段1  字段2  字段3
cnbj   中国   北京
cnsh   中国   上海
mgny   美国   纽约

在 combobox中如果想显示字段2+字段3的内容 

使用convet

先定义个函数

1
2
3
function seltext(v, record) {
    return record.字段2+ record.字段3;
}

 

然后在store的reader中加入covert,如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
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}]//这里
 
    })
});
1
  

最后就可以在combobox中将displayField属性设置为seltext

1
2
3
4
5
6
7
8
9
10
xtype: 'combo',
fieldLabel: '区域',
store: comboxStore,
mode: 'remote',
displayField: 'selecttext',//这里
triggerAction: 'all',
name: 'area',
emptyText: '请选择区域…',
editable: false,
anchor: '95%'

至此就可以在combobox中显示两个字段内容

posted @   jadebug  阅读(2374)  评论(0编辑  收藏  举报
编辑推荐:
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· PostgreSQL 和 SQL Server 在统计信息维护中的关键差异
· C++代码改造为UTF-8编码问题的总结
阅读排行:
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 清华大学推出第四讲使用 DeepSeek + DeepResearch 让科研像聊天一样简单!
· 实操Deepseek接入个人知识库
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
点击右上角即可分享
微信分享提示