//extjs4下的下拉框,目前store得写在控件里面,具体原因未知
1 xtype: 'container',
2 anchor: '100%',
3 layout: 'hbox',
4 items: [{
5 xtype: 'container',
6 flex: 1,
7 layout: 'anchor',
8 items: [{
9 xtype: 'combo',
10 fieldLabel: '客户全称',
11 //afterLabelTextTpl: required,
12 name: 'kehqc',
13 anchor: '95%',
14 valueField: 'name',
15 displayField: 'name',
16 triggerAction: 'all',
17 queryMode: 'local',
18 //autoLoad:true,
19 //store分开写会报错,目前原因不明
20 store: new Ext.data.Store({
21 singleton: true,
22 proxy: {
23 type: 'ajax',
24 url: 'BLL/H_suipkjBLL.aspx?action=cblist',
25 actionMethods: 'post',
26 reader: {
27 type: 'json',
28 root: 'root'
29 }
30 },
31 fields: ['name'], //不管有没有model,这个fields都必须写,而且只能写在这里,
32 //在reader里面的话会报错"reader.read is not a function"原因暂时不详
33 autoLoad: true
34 }),
35 loadingText: '正在加载数据,请稍侯……',
36 triggerAction: 'all',
37 valueField: 'name',
38 displayField: 'name',
39 listeners: {//客户和其他信息的联动
40 'select': function (combo, record, index) {
41 //alert(combo.value),
42 Ext.Ajax.request
43 ({
44 params: { parakehqc: combo.value }, //发送的参数
45 url: "BLL/H_suipkjBLL.aspx?action=cblink", //请求的地址
46 success: function (response, option) {
47 var rlnoteinfo = response.responseText;
48 var aryinfo = new Array();
49 aryinfo = rlnoteinfo.split("|");
50 fp.getForm().findField('guossh').setValue(aryinfo[0]);
51 fp.getForm().findField('kaihyh').setValue(aryinfo[1]);
52 fp.getForm().findField('yinhzh').setValue(aryinfo[2]);
53 fp.getForm().findField('gongsdz').setValue(aryinfo[3]);
54 fp.getForm().findField('lianxdh').setValue(aryinfo[4]);
55 }
56 });
57 }
58}
![]()
写死的外部store
//下面这些写在ext.require下面,ext.onready外面
var states = [
{ "id": "01", "name": "通路/二批" },
{ "id": "02", "name": "餐饮" },
{ "id": "03", "name": "夜场" },
{ "id": "04", "name": "商超" },
{ "id": "05", "name": "婚宴/团购" },
{ "id": "06", "name": "其他" },
{ "id": "99", "name": "不区分层面" }
];
function createStore() {
// The data store holding the states; shared by each of the ComboBox examples below
return Ext.create('Ext.data.Store', {
autoDestroy: true,
model: 'State',
data: states
});
}
//下面为combox内容
xtype: 'combobox',
id: 'cengm',
typeAhead: true,
triggerAction: 'all',
queryMode: 'local',
selectOnTab: true,
lazyRender: true,
displayField: 'name',
valueField: 'id',
store: createStore()
测试可用,使用ajax获取json暂时未测试