下拉菜单组件
this.form = Ext.widget('form', {
border: true,
bodyPadding: 10,
autoScroll: true,
layout: 'column',
defaults: {
anchor: '100%'
},
defaultType: 'textfield',
items: [
{
xtype: 'fieldcontainer',
layout: 'hbox',
combineErrors: true,
defaultType: 'textfield',
defaults: {
labelWidth: 100,
labelAlign: 'right',
anchor: '100%',
margin: '0 10 10 0',
width: 200
},
items: [
{
fieldLabel:'品牌商',
name:'company_code',
labelWidth: 50,
xtype: 'combo',
store: this.AllSaleCompanyStore,
queryMode: 'local',
displayField: 'name',
valueField: 'code',
editable: true,
width: 200
}
]
},
],
buttonAlign: 'left',
buttons: [
{
text: '重置',
scope: this,
handler: this.onBtnClick
},
{
text: '检索',
scope: this,
handler: this.onBtnClick
},
]
});
请求数据方法:
getSaleCompany: function () {
this.setLoading("加载中...");
var url = 'index.php/supplier_manage/supplier_search?type=2&del_flag=1';
Ext.Ajax.request({
url: url,
method: 'get',
async: false,//重点 异步加载 一般出现 “全部” 不能默认自动加载 问题一般就是出现在这
scope: this,
success: function (response, options) {
try {
var returnobj = Ext.JSON.decode(response.responseText);
if (returnobj) {
var Allreturnobj = Ext.JSON.decode(response.responseText);
for (var i = 0; i < returnobj.records.length; i++) {
returnobj.records[i].code = returnobj.records[i].company_code;
returnobj.records[i].name = (returnobj.records[i].company_name;
}
Allreturnobj.records.unshift({id: "", name: "全部", code: ''});
this.AllSaleCompanyStore.loadData(Allreturnobj.records);
}
} catch (e) {
Ext.Msg.alert("错误", response.responseText);
}
},
failure: function (response, options) {
Ext.Msg.alert("错误", response.responseText);
},
callback: function () {
this.setLoading(false);
}
});
},
加载数据
afterRenderHandler: function () {
this.getSaleCompany();
var field = this.form.getForm().findField("company_code");
field.select(field.getStore().getAt(0));
this.loadData();
},