项目需要一个根据运营商选择旗下加盟商的联动搜索
//创建好上下级下拉框store
var firstCombo = Ext.create('Ext.data.Store', {
fields: ['comIndexId', 'comName'],
autoLoad: true,
proxy: {
type: 'ajax',
url: '/Page/Combo1.ashx/GetData',
reader: {
type: 'json',
root: 'root'
}
}
});
var secondCombo = Ext.create('Ext.data.Store', {
fields: ['brandId', 'brandName'],
autoLoad: true,
proxy: {
type: 'ajax',
url: '/Page/Combo2.ashx/GetData',
reader: {
type: 'json',
root: 'root'
}
}
});
//将下拉框放入items中
items: [{
xtype: 'combo',
fieldLabel: '运营商',
editable: false,
multiSelect: false,
name: 'comIndexId',
width: 260,
displayField: 'comName',
valueField: 'comIndexId',
value: '',
store: firstCombo,
listeners: {
select: function (combo, record, index) {
secondCombo.on('beforeload', function (store, options) {
var new_params = { //传参,获取二级下拉框数据
comIndexId: combo.value,
};
Ext.apply(secondCombo.proxy.extraParams, new_params);
});
secondCombo.load();
}
}
}, {
xtype: 'combo',
name: 'brandId',
fieldLabel: '加盟商',
editable: false,
multiSelect: false,
name: 'brandId',
width: 200,
displayField: 'brandName',
valueField: 'brandId',
value: '',
store: secondCombo
}, {
xtype: 'button',
name: 'search',
text: '查询',
handler: function () {
var grid = this.up("grid");
var brandId = grid.down('[name=brandId]');
var comIndexId = grid.down('[name=comIndexId]');
grid.store.proxy.extraParams['brandId'] = brandId.getValue();
grid.store.proxy.extraParams['comIndexId'] = comIndexId.getValue();
grid.store.loadPage(1);
}
}]
网友评论