您可以在combobox 和开始日期 datefield 添加侦听器以侦听change( this, newValue, oldValue, eOpts ) 事件。
然后检查是否选择了combobox 和开始日期 datefield。如果它是真的将ajax.request 发送到您的服务器并为您的结束日期datefield
获得价值
这是一个示例,说明了许多解决方案之一(相当伪代码):
查看
Ext.define('YourPanel', {
extend: 'Ext.panel.Panel',
alias: 'widget.yourPanel',
xtype: 'yourPanel',
items:[{
xtype: 'combobox',
itemId: 'approachCountId'
},{
xtype: 'datefield',
itemId: 'dateStartId'
},{
xtype: 'datefield',
itemId: 'dateEndId'
}]
});
控制器
Ext.define('YourController', {
extend: 'Ext.app.Controller',
init: function () {
var controller = this;
controller.control({
'yourPanel combobox#approachCountId': {
change: controller.changeEndDateValue
},'yourPanel combobox#dateStartId': {
change: controller.changeEndDateValue
}
})
},
changeEndDateValue: function(field, newValue, oldValue, eOpts){
var controller = this;
//YourCode here to check if combobox value and end date value are not empty.
if(!Ext.isEmpty(startDateField) && !Ext.isEmpty(approachCount)){
//Ajax call
Ext.Ajax.request({
method: 'POST',
url: 'yourUrlToCheck',
params: {
approachCount: approachValue,
startDate: startDateValue
},
scope: this,
success: function (result, response) {
//if success set value to End Date datefield
},
failure: function (result, response) {
}
});
}
}
});