extjs array数据代理 combobox不显示值
Ext.onReady(function(){varcities=[[1,"南京市"],[2,"无锡市"],[3,"苏州市"]];varproxy=newExt.data...
Ext.onReady(function(){ var cities = [ [1,"南京市"], [2,"无锡市"], [3,"苏州市"] ]; var proxy = new Ext.data.MemoryProxy(cities);
var City = Ext.define('City',{ extend:'Ext.data.Model', field:[ {name:'cid',type:'int',mapping:0}, {name:'cname',type:String,mapping:1} ] }); var store = new Ext.data.ArrayStore({ model:'City', proxy:{ type: 'memory', reader: 'array' } }); store.loadData(cities,true); var comboBox = new Ext.form.ComboBox({ renderTo:Ext.getBody(), triggerAction:'all', store:store, displayField:'cname', valueField:'cid', queryMode:'local', emptyText:'请选择城市' }); var btn = new Ext.button.Button({ text:'列表框的值', renderTo:Ext.getBody(), handler:function(){ Ext.Msg.alert("值","实际值:"+comboBox.getValue()+",显示值:"+comboBox.getRawValue()); } }); }); 展开
var City = Ext.define('City',{ extend:'Ext.data.Model', field:[ {name:'cid',type:'int',mapping:0}, {name:'cname',type:String,mapping:1} ] }); var store = new Ext.data.ArrayStore({ model:'City', proxy:{ type: 'memory', reader: 'array' } }); store.loadData(cities,true); var comboBox = new Ext.form.ComboBox({ renderTo:Ext.getBody(), triggerAction:'all', store:store, displayField:'cname', valueField:'cid', queryMode:'local', emptyText:'请选择城市' }); var btn = new Ext.button.Button({ text:'列表框的值', renderTo:Ext.getBody(), handler:function(){ Ext.Msg.alert("值","实际值:"+comboBox.getValue()+",显示值:"+comboBox.getRawValue()); } }); }); 展开
展开全部
Ext.onReady(function() {
var store = Ext.create('Ext.data.Store', {
fields : ['cid', 'cname'],
data : [{
cid : '1',
cname : '南京市'
}, {
cid : '2',
cname : '无锡市'
}, {
cid : '3',
cname : '苏州市'
}]
});
var comboBox = new Ext.form.ComboBox({
renderTo : Ext.getBody(),
triggerAction : 'all',
store : store,
displayField : 'cname',
valueField : 'cid',
queryMode : 'local',
emptyText : '请选择城市'
});
var btn = new Ext.button.Button({
text : '列表框的值',
renderTo : Ext.getBody(),
handler : function() {
Ext.Msg.alert("值", "实际值:" + comboBox.getValue()
+ ",显示值:" + comboBox.getRawValue());
}
});
});
效果图:
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询