Ext.namespace("com.deng"); Ext.onReady(function(){ var cities = [ [1,"长沙市"],[2,"株洲市"],[3,"湘潭市"],[4,"邵阳市"] ]; var proxy = new Ext.data.MemoryProxy(cities); var city = new Ext.data.Record.create([ {name:"cid",type:"int",mapping:0}, {name:"cname",type:"string",mapping:1} ]); //var reader = new Ext.data.ArrayReader({},city); var reader = new Ext.data.ArrayReader({},[ {name:"cid",type:"int",mapping:0}, {name:"cname",type:"string",mapping:1} ]); var store = new Ext.data.Store({ proxy: proxy, reader: reader, autoLoad: true //即时加载数据 }); //store.load(); var combobox = new Ext.form.ComboBox({ renderTo: Ext.getBody(), triggerAction: "all", store: store, displayField: "cname", valueField: "cid", mode:"local", emptyText:"请选择湖南城市" }); var btn = new Ext.Button({ text: "列表框的值", renderTo: Ext.getBody(), handler: function(){ Ext.Msg.alert("值","实际值:" + combobox.getValue() + ": 显示值:" + combobox.getRawValue()); } }); }); /** * 备注: * triggerAction: 是否开启自动查询的功能,为all表示不开启,为query表示开启,默认为query * store: 数据源 * displayField: 关联Record的某一个逻辑列名作为显示值 * valueField:关联Record的某一个逻辑列名作为实际值 * mode:可选值有local和remote,如果数据来自本地,用local,如果数据来自远程服务器,必须用remote,默认为remote * emptyText:没有选择任何选项的情况文本框的默认文字 * getValue(),用于返回实际值,getRawValue()用于返回显示值 * * */
Ext学习之7_下拉列表框
最新推荐文章于 2021-06-04 12:51:06 发布