项目中需要为行编辑器Editor的某个列的文本框添加改变事件

需求:新增行时,为用户名输入特殊字符进行验证,不允许保存用户数据

html页面

 <table  id="gridlist" data-bind="datagrid:grid" >
<thead>
<tr>
<th field="ck" checkbox="true" readOnly:true ></th>
<th field="OptimisticLockField" hidden="true"></th>
<th field="UserCode" sortable="true" align="left" width="80" editor="{type:'validatebox',options:{required: true }}" >用户名 </th>
<th field="UserName" sortable="true" align="left" width="200" editor="{type:'validatebox',options:{required: true }}" >名称 </th>
<th field="OriginalPassword" sortable="true" align="left" width="200" >密码 </th>
<th field="Org" sortable="true" align="left" width="200" editor="{type:'lookup',options:{required:true,lookupType:'cloud.PcsOrg',window:{title:'所属机构'},queryParams:{State:9,Ou:false}}}" formatter="formatOrg" >所属机构 </th>
<th field="IsEnable" sortable="true" align="center" width="120" editor="{type:'checkbox',options:{on:1,off:0}}" formatter="com.formatCheckbox" >是否可用</th>
<th field="IsAdmin" align="center" width="120" editor="{type:'checkbox',options:{on:1,off:0}}" formatter="com.formatCheckbox">是否管理员</th>
<th field="LoginCount" sortable="true" align="right" width="120" >登录次数</th>
<th field="LastLoginDate" sortable="true" align="left" width="135" formatter="com.formatDate">最后登录日期</th>
<th field="LastLoginOU" align="left" width="170" hidden="true" >最后登录组织</th>
<th field="OrganizeNames" align="left" width="170">最后登录组织</th>
<th field="Permit" align="center" width="320" formatter="formatterButton"> 操作 </th>
<th field="Description" align="left" width="150" editor="text">描述</th>
</tr>
</thead>
</table>

js代码:

       //创建editor编辑器之后执行事件
this.grid.OnAfterCreateEditor = function (editors,row) {
//编辑器userCode添加改变事件
if (row != undefined && row._isnew!=undefined) {
editors["UserCode"].target.bind("change",function()
{
var getUser = editors["UserCode"].target.val();
//判断新增状态下用户名只能使用数字或着字母或着下划线
if (!/^[\w]+$/.test(getUser)) {
com.message('error', '用户名只能数字、字母、下划线.');
return;
}
});
}
}

页面效果:

总结:

使用easyui的datagrid的OnAfterCreateEditor事件,通过 editors["UserCode"].target.bind("change",function(){ } 绑定改变事件,其中获取文本框的值的语法是:

 editors["UserCode"].target.val(); 

//创建editor编辑器之后执行事件
        this.grid.OnAfterCreateEditor = function (editors,row) {          
            //编辑器userCode添加改变事件
            if (row != undefined && row._isnew!=undefined) {
            editors["UserCode"].target.bind("change",function()
            {               
                var getUser = editors["UserCode"].target.val();                   
                //判断新增状态下用户名只能使用数字或着字母或着下划线
                if (!/^[\w]+$/.test(getUser)) {
                    com.message('error', '用户名只能数字、字母、下划线.');
                    return;                 
                }             
            });
            }          
        }

easyui datagrid的editor编辑器如何为validatebox控件添加改变事件的更多相关文章

  1. Jquery easyui的validatebox控件和正则表达式

    http://blog.csdn.net/dandanzmc/article/details/36421465 仔细观察jquery.validatebox.js文件,会发现它的验证其实还是采用的正则 ...

  2. 基于MVC4+EasyUI的Web开发框架形成之旅--界面控件的使用

    在前面介绍了两篇关于我的基于MVC4+EasyUI技术的Web开发框架的随笔,本篇继续介绍其中界面部分的一些使用知识,包括控件的赋值.取值.清空,以及相关的使用. 我们知道,一般Web界面包括的界面控 ...

  3. 转--基于MVC4+EasyUI的Web开发框架形成之旅--界面控件的使用

    原文  http://www.cnblogs.com/wuhuacong/p/3317223.html 基于MVC4+EasyUI的Web开发框架形成之旅--界面控件的使用 在前面介绍了两篇关于我的基 ...

  4. Unity编辑器 - 鼠标悬停在控件上时改变鼠标样式

    Unity编辑器 - 鼠标悬停在控件上时改变鼠标样式 摘自Unity文档 EditorGUIUtility.AddCursorRect public static void AddCursorRect ...

  5. Unity编辑器 - 使用GL绘制控件

    Unity编辑器 - 使用GL绘制控件 控件较为复杂时,可能造成界面卡顿,在EditorGUI中也可以灵活使用GL绘制来提升性能. 以绘制线段为例: using UnityEngine; using ...

  6. Unity编辑器 - DragAndDrop拖拽控件

    Unity编辑器 - DragAndDrop拖拽控件 Unity编辑器的拖拽(DragAndDrop)在网上能找到的资料少,自己稍微研究了一下,写了个相对完整的案例,效果如下 代码: object d ...

  7. JQuery easyUi datagrid 中 editor 动态设置最大值最小值

    前言 近来项目中使用到 easyui 来进行页面设计,感觉挺方便的,但是网上除了api外,其他有价值的资料比较少,故在此分享一点经验,供大家参考.   问题 JQuery easyUi datagri ...

  8. (转)基于MVC4+EasyUI的Web开发框架形成之旅--界面控件的使用

    原文地址:http://www.cnblogs.com/wuhuacong/p/3317223.html 在前面介绍了两篇关于我的基于MVC4+EasyUI技术的Web开发框架的随笔,本篇继续介绍其中 ...

  9. 给EasyUI的DateBox控件添加清除button

     EasyUI中间DateBox控制甚至没有被清除button.例如下面的附图: 真是不可思议,对于要求日期格式必须选择的情况下,不能清空日期,很不方便.      尽管能够通过手工改动EasyU ...

随机推荐

  1. mybatis update 返回值

    mybatis sql: <update id="test" parameterType="map"> update test_0731 set n ...

  2. Docker 0x02: Docker生态

    目录 Docker生态 Docker官网 0x00 网址 Docker组件 0x01. docker-client 与 docker-daemon 0x02. docker镜像 0x03. docke ...

  3. 【Maven】Maven中排除依赖、归类依赖、优化依赖

    参考博文:Maven中排除依赖.归类依赖.优化依赖

  4. Odoo中的ORM API(模型数据增删改查)

    转载请注明原文地址:https://www.cnblogs.com/ygj0930/p/10826214.html 一:增 1:create():返回新创建的记录对象 self.create({'na ...

  5. HTTP认识

    一.相关名词解释 1. 超文本:是指包含指向其他文档的超链接的文本 2. 万维网:简称web,是一个分布式的超媒体系统,它是超文本系统的扩充,以客户-服务器方式工作 3. 超媒体:文档包含文本,图片, ...

  6. Java SpringBoot 手记

    SpringBoot Git:https://github.com/spring-projects/spring-boot Maven (mvn)环境配置: 下载地址:http://maven.apa ...

  7. 将源码包制作成rpm包

    Linux系统中一般安装软件有两种方法,源码安装和yum安装或者rpm包安装,由于光盘中的rpm包都是几年前制作成的,所以软件版本都很低,同时yum安装对软件的可定制性很低,所以为了使用最新的软件,一 ...

  8. Vue开发之基础路由

    1.router-link和router-view组件 src/App.vie文件内容: <template> <div id="app"> <div ...

  9. spring mvc @RequestMapping method 不写的话,默认GET、POST都支持,根据前端方式自动适应

    @RequestMapping(value="/") method 不写的话,默认GET.POST都支持,根据前端方式自动适应.

  10. java内部类的本质

    连接与通信,作为桥接中间件存在. 内部类和主体类可以无障碍通信: 1.通过继承连接实现: 2.通过接口连接通信: 形式: 1.命名空间: 2.运行上下文: 其它: 信息隐藏是次要功能. 内部类 Jav ...