- Ext.onReady(function () {
- Ext.QuickTips.init();
- var comStore = Ext.create('Ext.data.Store', {
- fields: ['cityID', 'cityName'],
- // data : [
- // {"cityID":"sx", "cityName":"陕西"},
- // {"cityID":"shh", "cityName":"上海"},
- // {"cityID":"sc", "cityName":"四川"}
- // ]//,
- pageSize: 10,
- proxy: {
- type: 'ajax',
- url: 'getComboxValue.action',
- reader: {
- type: 'json',
- successProperty: 'success',
- root: 'datas'
- }
- }
- });
- var panel = Ext.create('Ext.form.Panel', {
- title: '异步加载combox值示例',
- renderTo: 'ddd',
- bodyPadding: '10 0 10 0',
- height: 150,
- width: 300,
- frame: true,
- defaults: {
- labelSeparator: ':',
- allowBlank: false,
- msgTarget: 'side',
- labelAlign: 'right'
- },
- items: [{
- xtype: 'combobox',
- listConfig: {
- emptyText: '没有找到匹配的信息',
- maxHeight: 200,
- //模板功能
- getInnerTpl: function () {
- return "<div class'{c}'>{cityID}-{cityName}</div>";
- }
- },
- fieldLabel: '省份或城市',
- name: 'city',
- queryMode: 'remote',
- store: comStore,
- minChars: 1,
- triggerAction: 'all',
- //multiSelect:true, //允许多选
- queryParam: 'cityName', //查询参数
- queryDelay: 1000, //延时1秒加载
- pageSize: 10, //页面显示条数分页使用
- valueField: 'cityID', //后台数据不显示的key
- displayField: 'cityName' //后台数据要显示的value
- }]
- });
- })
- //该片段来自于http://www.codesnippet.cn/detail/040520149441.html
来源: http://www.codesnippet.cn/detail/040520149441.html