Extjs4 表单ajax验证
Extjs4 表单ajax验证
xtype: 'combobox',
labelAlign: 'right',
fieldLabel: '业务单元',
name: 'CATE_TYPE',
labelWidth: 150,
queryMode:'remote',
store: ,
editable:false, //是否允许输入
emptyText:'请选择一个平台',
allowBlank: false,
blankText: '请选择一个平台',
width:400,
triggerAction:'all', //显示所有下列数.必须指定为'all'
valueField:'value', //传送的值
displayField:'text', //UI列表显示的文本
validationOnBlur : false, //失去焦点时进行验证
textValid: false,
validationOnChange : true, //发生改变时进行验证
validator: function(){
return this.textValid;
},
listeners: {
change: function(obj, newValue, oldValue, eOpts){
var cate_type_value = obj.getValue();
var bedget_datetime_value = Ext.getCmp('BUDGET_DATETIME').getValue();
Ext.Ajax.request({
url: '',
params: {
BUDGET_DATETIME: bedget_datetime_value,
CATE_TYPE: cate_type_value
},
method: 'POST',
success: function (response, options) {
var result = Ext.JSON.decode(response.responseText);
var success = result.success;
if(success){
this.clearInvalid();
this.textValid = true;
}else{
this.markInvalid(result.msg);//这个方法可以给表单组件加上红圈圈和悬浮提示
obj.textValid = false;
}
},
failure: function (response, options) {
obj.textValid = false;
}
});
}
}

浙公网安备 33010602011771号