Extjs4的本地下拉框
下面是客户端代码:
<script>
//定义store
var states = Ext.create('Ext.data.Store', {
fields: ['id', 'name'],
data : [
{"value":"beijing", "name":"北京"},
{"value":"tianjin", "name":"天津"},
{"value":"shanghai", "name":"上海"},
{"value":"chongqing", "name":"重庆"},
//...
]
});
//定义grid
Ext.define('MyApp.view.ui.MyForm', {
extend: 'Ext.form.Panel',
height: 250,
width: 400,
bodyPadding: 10,
title: '表单',
initComponent: function() {
var me = this;
me.items = [
{
xtype: 'combobox',
name:'state',
fieldLabel: '选择地区',
store:states,//指定数据源
valueField:'value',//指定作为值的字段
displayField:'name',//指定显示的字段
queryModel:'local',//查询模式为本地
labelWidth: 60,
anchor: '50%'
}
];
me.callParent(arguments);
}
});
Ext.onReady(function(){
Ext.create('MyApp.view.ui.MyForm',{
renderTo:Ext.getBody()//渲染到body内
});
});
</script>
示意图: