- 浏览: 1465645 次
- 性别:
- 来自: 郑州
文章分类
最新评论
-
getelephantbyid:
make 无法通过.....
php-5.3,php-5.4的thttpd2.25b补丁,及编译方法 -
getelephantbyid:
patch -p1 ../php-5.4.7_thttpd-2 ...
php-5.3,php-5.4的thttpd2.25b补丁,及编译方法 -
zander:
zander 写道c 语言是静态类型语言还是动态类型语言阅读理 ...
什么是动态语言和静态语言? -
zander:
c 语言是静态类型语言还是动态类型语言
什么是动态语言和静态语言? -
lunajiayou:
很有道理,赞一个
跟着苍蝇会找到厕所,跟着蜜蜂会找到花朵
extjs 6.5本身不支持异步验证,只能执行js验证,异步验证需要自己实现
在一个Ext.data.validator里面执行Ajax请求,请求执行成功后执行回调函数,然后调用Ext.field.Field的setError方法显示错误并阻止表单提交。
关于setError和isValid可以参考源码
/**
* This method is called by {@link #method!validate validate} if the value is both
* non-empty (not `null`, `undefined` or `''`) and if the value can be parsed by the
* {@link #method!parseValue parseValue} method. This parsing concern is technically
* only in play for `Ext.field.Text` and derived classes (such as `Ext.field.Date` and
* `Ext.field.Number`) but the guarantee here is that the `value` will be a parsed
* value and not the raw string and if the value cannot be parsed, this method will
* not be called.
*
* @param {Mixed} value The (parsed) value
* @param {String[]} errors The array of validation errors
* @param {Boolean} [skipLazy] `false` (the default) to run all validators.
* @private
*/
doValidate: function (value, errors, skipLazy) {
var validators = this.getValidators(),
len = validators && validators.length,
i, result, validator;
for (i = 0; i
validator = validators[i];
if (!skipLazy || !validator.lazy) {
result = validator.validate(value);
if (result !== true) {
//
if (!result || typeof result !== 'string') {
Ext.raise('Validator did not return a valid result.');
}
//
errors.push(result);
}
}
}
},
parseValue: Ext.identityFn, // documented on textfield
/**
* Validate the field and return it's validity state.
* To get the existing validity state without re-validating current value,
* use {@link isValid}.
*
* @param {Boolean} [skipLazy] (private) Pass `true` to skip validators marked as `lazy`.
* @return {Boolean} The new validity state.
*/
validate: function (skipLazy) {
var me = this,
empty, errors, field, record, validity, value;
// If we are in configuration and not validating any values, skip out of here
if (me.isConfiguring && me.validateOnInit === 'none') {
return true;
}
// if field is disabled and cfg not set to validate if disabled, skip out of here
if (!me.getDisabled() || me.getValidateDisabled()) {
errors = [];
// If we are a textual input field, get the input element's value.
// Check the DOM validity state first in case a type="number"
// check has failed.
if (me.isInputField && !me.isSelectField) {
value = me.getInputValue();
empty = !value;
validity = empty && me.inputElement.dom.validity;
if (validity && validity.badInput) {
errors.push(me.badFormatMessage);
empty = false;
}
}
else {
value = me.getValue();
empty = value === '' || value == null;
}
if (empty && me.getRequired()) {
errors.push(me.getRequiredMessage());
}
else if (!errors.length) {
if (!empty) {
// Pass non-empty values along to parseValue to handle things like
// datefield and numberfield. Technically this concern is more of a
// textfield family issue, but it is awkward to leap out of this
// sequence in such a way as to make a surgical override practical...
// So we simply provide identityFn as the default parseValue impl
value = me.parseValue(value, errors);
}
if (!errors.length) {
field = me._validationField;
record = me._validationRecord;
if (field && record) {
field.validate(value, null, errors, record);
}
if (!empty) {
me.doValidate(value, errors, skipLazy);
}
}
}
if (errors.length) {
me.setError(errors);
return false;
}
}
me.setError(null);
return true;
},
当有错误显示时调用isValid就会为true,isValid的逻辑如下
/**
* Mark field as invalid.
* @deprecated 6.5.0 Use {@link #setError} instead. (for classic compatibility)
* @since 6.5.0
*/
markInvalid: function (messages) {
this.setError(messages);
},
/**
* Mark field as valid.
* @deprecated 6.5.0 Use {@link #setError setError(null)} instead. (for classic compatibility)
* @since 6.5.0
*/
clearInvalid: function () {
this.setError(null);
},
/**
* Returns true if field is valid.
*/
isValid: function () {
return !this.getError();
},
为了使ajax回调时能获得field的引用需要修改doValidate的代码,把field的引用传递过去
result = validator.validate(value,this);
[code="js"]/**
* Created by hetao on 2017/10/12.
*/
Ext.define('overrides.field.Field', {
override:'Ext.field.Field',
/**
* This method is called by {@link #method!validate validate} if the value is both
* non-empty (not `null`, `undefined` or `''`) and if the value can be parsed by the
* {@link #method!parseValue parseValue} method. This parsing concern is technically
* only in play for `Ext.field.Text` and derived classes (such as `Ext.field.Date` and
* `Ext.field.Number`) but the guarantee here is that the `value` will be a parsed
* value and not the raw string and if the value cannot be parsed, this method will
* not be called.
*
* @param {Mixed} value The (parsed) value
* @param {String[]} errors The array of validation errors
* @param {Boolean} [skipLazy] `false` (the default) to run all validators.
* @private
*/
doValidate: function (value, errors, skipLazy) {
var validators = this.getValidators(),
len = validators && validators.length,
i, result, validator;
console.log(this);
for (i = 0; i
if (!result || typeof result !== 'string') {
Ext.raise('Validator did not return a valid result.');
}
//
errors.push(result);
}
}
}
},
});
然后自己定义验证器里面这样写
validate: function(value,formField) {
Ext.Ajax.request({
url : 'rest/users?action=validate&username=' + newValue,
scope:formField,
success : function(response) {
// Ausuming responseText is {"valid" : true}
var validFlag = Ext.decode(response.responseText).valid ? true : 'The username is duplicated!';
if(validFlag!=true)
{
this.setError(validFlag);
}
}
return true;
}
return true;
}
在一个Ext.data.validator里面执行Ajax请求,请求执行成功后执行回调函数,然后调用Ext.field.Field的setError方法显示错误并阻止表单提交。
关于setError和isValid可以参考源码
/**
* This method is called by {@link #method!validate validate} if the value is both
* non-empty (not `null`, `undefined` or `''`) and if the value can be parsed by the
* {@link #method!parseValue parseValue} method. This parsing concern is technically
* only in play for `Ext.field.Text` and derived classes (such as `Ext.field.Date` and
* `Ext.field.Number`) but the guarantee here is that the `value` will be a parsed
* value and not the raw string and if the value cannot be parsed, this method will
* not be called.
*
* @param {Mixed} value The (parsed) value
* @param {String[]} errors The array of validation errors
* @param {Boolean} [skipLazy] `false` (the default) to run all validators.
* @private
*/
doValidate: function (value, errors, skipLazy) {
var validators = this.getValidators(),
len = validators && validators.length,
i, result, validator;
for (i = 0; i
validator = validators[i];
if (!skipLazy || !validator.lazy) {
result = validator.validate(value);
if (result !== true) {
//
if (!result || typeof result !== 'string') {
Ext.raise('Validator did not return a valid result.');
}
//
errors.push(result);
}
}
}
},
parseValue: Ext.identityFn, // documented on textfield
/**
* Validate the field and return it's validity state.
* To get the existing validity state without re-validating current value,
* use {@link isValid}.
*
* @param {Boolean} [skipLazy] (private) Pass `true` to skip validators marked as `lazy`.
* @return {Boolean} The new validity state.
*/
validate: function (skipLazy) {
var me = this,
empty, errors, field, record, validity, value;
// If we are in configuration and not validating any values, skip out of here
if (me.isConfiguring && me.validateOnInit === 'none') {
return true;
}
// if field is disabled and cfg not set to validate if disabled, skip out of here
if (!me.getDisabled() || me.getValidateDisabled()) {
errors = [];
// If we are a textual input field, get the input element's value.
// Check the DOM validity state first in case a type="number"
// check has failed.
if (me.isInputField && !me.isSelectField) {
value = me.getInputValue();
empty = !value;
validity = empty && me.inputElement.dom.validity;
if (validity && validity.badInput) {
errors.push(me.badFormatMessage);
empty = false;
}
}
else {
value = me.getValue();
empty = value === '' || value == null;
}
if (empty && me.getRequired()) {
errors.push(me.getRequiredMessage());
}
else if (!errors.length) {
if (!empty) {
// Pass non-empty values along to parseValue to handle things like
// datefield and numberfield. Technically this concern is more of a
// textfield family issue, but it is awkward to leap out of this
// sequence in such a way as to make a surgical override practical...
// So we simply provide identityFn as the default parseValue impl
value = me.parseValue(value, errors);
}
if (!errors.length) {
field = me._validationField;
record = me._validationRecord;
if (field && record) {
field.validate(value, null, errors, record);
}
if (!empty) {
me.doValidate(value, errors, skipLazy);
}
}
}
if (errors.length) {
me.setError(errors);
return false;
}
}
me.setError(null);
return true;
},
当有错误显示时调用isValid就会为true,isValid的逻辑如下
/**
* Mark field as invalid.
* @deprecated 6.5.0 Use {@link #setError} instead. (for classic compatibility)
* @since 6.5.0
*/
markInvalid: function (messages) {
this.setError(messages);
},
/**
* Mark field as valid.
* @deprecated 6.5.0 Use {@link #setError setError(null)} instead. (for classic compatibility)
* @since 6.5.0
*/
clearInvalid: function () {
this.setError(null);
},
/**
* Returns true if field is valid.
*/
isValid: function () {
return !this.getError();
},
为了使ajax回调时能获得field的引用需要修改doValidate的代码,把field的引用传递过去
result = validator.validate(value,this);
[code="js"]/**
* Created by hetao on 2017/10/12.
*/
Ext.define('overrides.field.Field', {
override:'Ext.field.Field',
/**
* This method is called by {@link #method!validate validate} if the value is both
* non-empty (not `null`, `undefined` or `''`) and if the value can be parsed by the
* {@link #method!parseValue parseValue} method. This parsing concern is technically
* only in play for `Ext.field.Text` and derived classes (such as `Ext.field.Date` and
* `Ext.field.Number`) but the guarantee here is that the `value` will be a parsed
* value and not the raw string and if the value cannot be parsed, this method will
* not be called.
*
* @param {Mixed} value The (parsed) value
* @param {String[]} errors The array of validation errors
* @param {Boolean} [skipLazy] `false` (the default) to run all validators.
* @private
*/
doValidate: function (value, errors, skipLazy) {
var validators = this.getValidators(),
len = validators && validators.length,
i, result, validator;
console.log(this);
for (i = 0; i
if (!result || typeof result !== 'string') {
Ext.raise('Validator did not return a valid result.');
}
//
errors.push(result);
}
}
}
},
});
然后自己定义验证器里面这样写
validate: function(value,formField) {
Ext.Ajax.request({
url : 'rest/users?action=validate&username=' + newValue,
scope:formField,
success : function(response) {
// Ausuming responseText is {"valid" : true}
var validFlag = Ext.decode(response.responseText).valid ? true : 'The username is duplicated!';
if(validFlag!=true)
{
this.setError(validFlag);
}
}
return true;
}
return true;
}
发表评论
-
ExtJs selectfield字段样式错乱
2018-08-01 07:11 794Ext.field.Select 如果有required ... -
阻止表单提交的正确方法
2018-07-26 14:49 735一, form标签中加入onsubmit=" ... -
extjs virtual store不触发load,before等事件
2018-03-29 00:29 532这些事件虽然原生store中可以正常使用,而且virtua ... -
extjs给组件的对象中的某个属性赋值的方法
2018-03-17 03:37 1626这样是对的form.getViewModel().set( ... -
浏览器用户代理分析工具
2018-01-27 16:09 533https://www.browserua.me/ ... -
解决extjs不能在android8.0上打开的问题
2018-01-24 18:37 916sencha extjs 6.5.3版本已解决此问题 原 ... -
解决extjs在ios微信上页面整 体向下偏移20px的问题
2018-01-24 17:11 1158viewport:{ scrol ... -
扩展mint-ui tabbar使用链接导航
2018-01-08 00:47 7642<template> <a cla ... -
ExtJS添加自定义事件的两种方法
2017-12-13 22:24 1070方法一 listeners:[ { elem ... -
ExtJS无限滚动
2017-12-13 19:01 787实现无限滚动只需要在store上做工作就可以了 extj ... -
navigationview的使用
2017-12-13 18:57 1122navigationview的使用 navigation ... -
Extjs组件查找
2017-11-01 20:34 625组件创建了,就有方法找到这些组件。在DOM、Jquery都 ... -
extjs的treestore
2017-10-11 00:45 1426treestore的定义 sumTypeTree: ... -
extjs的视图模型和绑定
2017-10-11 00:41 675深度绑定 myinfo: { autoL ... -
vmware中运行的macos连接iphone
2017-09-30 17:53 2315需要iphone插在usb2.0端口上,并且虚拟机usb兼容性 ... -
extjs和yii跨域问题解决
2017-08-27 20:03 1305Extjs 只是跨域extjs并不需要特别的设置,但是默 ... -
brotli压缩算法说明
2017-06-09 02:36 1300brotli是新一代的HTTP压缩算法,用于替代gzip,相 ... -
TLS1.3说明
2017-06-09 02:40 894加速原理 TLS1.2需要两个RTT协商密钥,TLS1.3 ... -
TCP Fast Open说明
2017-06-09 02:34 7075相关介绍 https://lwn.net/Article ... -
禁用htc one m7官方内核的写保护
2014-08-26 14:52 1283老外写的内核模块源码:https://github.com ...
相关推荐
EXTJS 6.5 商用版 移除试用水印 ,加入完整商用版 .JS 直接使用,
ExtJs6.5官方文档
### Extjs6.5快速开始知识点详解 #### 一、Extjs6.5简介与Hello World应用 **介绍** - **快速入门指南目的**: 旨在帮助开发者快速掌握Ext JS的核心概念,成为有效的Ext JS开发人员。 - **学习方法**: 结合工作代码...
在ExtJs 6.5版本中,开发人员经常需要实现数据导出功能,特别是对于Grid组件,这是一项常见的需求。Grid列表通常用于展示大量结构化的数据,而导出功能可以帮助用户将这些数据保存到本地,方便进一步分析或共享。...
ExtJS 6.2与Sencha Cmd 6.5.3.6是Web应用程序开发中的两个关键工具,尤其在构建基于JavaScript的富客户端应用时。本文将深入探讨这两个组件及其在Windows 64位环境下的使用。 首先,ExtJS是一个强大的JavaScript...
本工程涵盖了 Ext Js Modern 开发的各方面的基础知识, 比如开发环境搭建, 项目结构详解, 如何使用 api, 数据的增删查该基本示例, 以实际操作为主,非常好的入门项目 本书的各章节之间有一定的知识关联, 由浅至...
"ExtJs6.5 日历导航+日历月视图面板.rar"是一个示例项目,展示了如何在Modern Toolkit下使用日历导航和月视图控件。 1. **日历导航**: 在ExtJS中,日历导航通常涉及到日期选择器和时间选择器组件,如`Ext.picker....
ExtJS是一种广泛使用的JavaScript框架,专门用于构建富客户端Web应用程序。6.5.0是其一个重要的版本,引入了许多新特性、改进和扩展,特别是针对“morden”组件的增强,使得它更适合现代Web开发的需求。 在ExtJS ...
异步加载树型是 ExtJS Tree 的一个重要特性,允许只在需要时动态加载子节点,从而提高页面的加载速度和用户体验。 异步加载通常通过 AJAX 请求实现,只有当用户展开一个节点时,才会向服务器请求该节点的子节点数据...
extjs-6.5.3离线API文档,是学习和开发的必要工具。希望有所帮助!
同时,EXTJS的`Ext.Ajax`或`Ext.data.proxy.Ajax`模块用于与服务器进行异步通信,实现数据的CRUD操作。 3. **视图与控制器**:EXTJS的MVC(Model-View-Controller)架构使得代码组织清晰。产品级别的视图可能包含多...
ExtJS是一个强大的JavaScript库,专用于构建富客户端的Web应用程序。它提供了丰富的组件库,包括表格、树形视图、图表和其他多种UI元素。在本例"ExtJS-MVC-用户列表实例"中,我们将深入探讨如何利用ExtJS的Model-...
官方提供的主题并不是很多,这些是经过提取的主题,界面美观,又大气
extjs验证 extjs验证 extjs验证 extjs验证extjs验证 extjs验证 extjs验证 extjs验证
在ExtJS 3中,实现异步下拉树涉及到几个关键概念和技术。 首先,理解“异步”意味着数据不是一次性加载完毕,而是按需加载。在下拉树中,当用户展开树节点时,只加载该节点及其子节点的数据,这减少了初始页面加载...
ExtJS是一种广泛使用的JavaScript库,专门用于构建富客户端应用程序。这个资源包包含了ExtJS API的中文版,方便中国开发者理解和使用。API文档是任何开发框架的核心部分,它提供了详细的类、方法、属性和事件的说明...
作为Extjs 4架构更新的一部分,我们引用了一个功能更完整的类系统。 无论何时,Extjs都会提供一个优秀的类系统,这次我们进一步为它添加了动态加载、mixins和在线依赖计算等特性。
在这个例子中,我们将深入探讨如何利用SSH整合来实现一个登录功能,并且这个功能的前端界面是通过ExtJS库创建的。 1. **Spring框架**:Spring是核心的依赖注入(DI)和面向切面编程(AOP)框架,它管理着应用中的...