[英]ExtJs and Java: Updating combobox
我有一个使用ExtJ创建的VehicleType组合框,当前正在通过使用以下代码在Java中调用的方法填充该组合框
VehicleType = this.VehicleType ;
Ext.apply(VehicleType , {
valueProvider: {
getValues: VehicleTypeService.getVehicleTypes
},
getDisplayValue: function(option) {
return option.value;
},
getServerValue: function(option) {
return option;
},
getInitValueParameters: function() {
return [region, manufactuerTypeId, vehicleType];
}
},
new Ext.controls.BaseSelectableMixin());
VehicleType.init();
调用的Java方法是VehicleTypeService.getVehicleTypes
,传递给Java方法的参数是函数getInitValueParameters
。 当我加载页面时工作正常,但是如果我在页面上更改此上方的组合框(ManufactuerType:与VehicleType完全相同,只是具有不同的值),我想根据所选内容刷新VehicleType组合框
最好的方法是什么?
我尝试扩展ComboSelectable以添加处理程序,但无法正常工作
Ext.controls.VehicleTypeComboSelectable = Ext.extend(Ext.controls.ComboSelectable, {
initComponent: function() {
Ext.controls.VehicleTypeComboSelectable.superclass.initComponent.call(this);
this.on("render", this.init.createDelegate(this));
}
,init : function() {
}
,handler : function() {
}
});
Ext.reg('ownershiptypecomboselectable', Extador.controls.OwnershipTypeComboSelectable);
尝试使用组合框的事件侦听器,然后使用商店的extraParams
,如下所示:
PS:我看不到您的ExtJS代码,因此我试图找出方法。
// store definition
var articleSub = new Ext.data.JsonStore({
model: 'ArticleSubGroup',
proxy: {
type: 'ajax',
url: '<?php echo base_url() ?>dashboard/promotion',
reader: {
type: 'json',
root: 'ArticleSubGroup',
idProperty: 'ID'
}
}
});
// combobox definition
{
xtype: 'combobox',
fieldLabel: 'MAL GRUBU',
store: articleBase,
id: 'art-base-group',
queryMode: 'local',
autoSelect: false,
forceSelection: true,
triggerAction: 'all',
editable: false,
valueField: 'PWG',
displayField: 'PWG_BEZ',
inputWidth: 240,
margin: '10 0 0 0',
listConfig: { cls: 'combo-dep' },
listeners: {
select: function(combo) {
// here we are populating another combobox based on the 'basegroup' parameter
articleSub.proxy.extraParams = {'basegroup': combo.getValue()}
articleSub.load();
}
}
}
// here is the another combobox which is populating by above combobox
// the tricks is 'store' parameter
// we are posting url parameter then load the store in above
{
xtype: 'combobox',
fieldLabel: 'ALT MAL GRUBU',
store: articleSub,
id: 'art-sub-group',
queryMode: 'local',
autoSelect: false,
forceSelection: true,
triggerAction: 'all',
editable: false,
valueField: 'PWUG',
displayField: 'PWUG_BEZ',
inputWidth: 240,
margin: '10 0 0 0',
listConfig: { cls: 'combo-dep' }
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.