zoukankan      html  css  js  c++  java
  • (原创)EasyUI中datagrid的行编辑模式中,找到特定的Editor,并为其添加事件

    有时候在行编辑的时候,一个编辑框的值要根据其它编辑框的值进行变化,那么可以通过在开启编辑时,找到特定的Editor,为其添加事件

    // 绑定事件, index为当前编辑行

    var editors = $('#staffLogDetailGrid').datagrid('getEditors', index);     //获得当前行的编辑对象

    console.info(editors[5]);  //editor[5]表示第五列这个控件

    var sfgzEditor = editors[5];

    sfgzEditor.target.bind('change',function () {

        console.info("111");

        console.info(sfgzEditor.target.val()); //sfgzEditor.target就是操作第五列控件对象

    });

    以上的edit类型是: 'validatebox',如下所示;

    editor : {

        type : 'validatebox',

        options : {

           required : true

        }

    }

    绑定的是change事件;即单元格的内容改变时(无须失去焦点,只要内容改变就行了);

    当然也可以绑定其他时间: 比如”blur”: 失去焦点的时候,实际中也有这种需求的, 比如一个单元格编辑完成后, 同时其他某些单元格的内容也会随之变化;

    Bind是绑定的意识,即绑定事件的功能;

    Change, blur, bind这些方法都在edit(Object).target里面; console.info(editors[5]);就可以在网页测试工具中查看到;

    里面还有很多事件可以用

     

    Type为'validatebox'的本人已经亲测过,是可以的; 可是type为’combobox’好像change和blur事件都无法正常触发;可是我看到 console.info(editors[5]);

    输出的target 属性值为:

     

    Object[input.combobox-f]

     

    这是一个combobox对象;可以直接对其赋事件的; 所以代码如下:

    // 绑定事件

    var editors = $('#staffLogDetailGrid').datagrid('getEditors', lastIndex);     

    console.info(editors[3]);

    var sfgzEditor = editors[3];

    var sfgzCobobox = sfgzEditor.target;

    console.info(sfgzCobobox);

    sfgzCobobox.combobox({  

        onChange : function(n,o){

    console.info("111");

        }

    });

    这样就可以给type为combobox的edit绑定事件了;

  • 相关阅读:
    shell脚本编程-结构化命令3-while、until命令
    shell脚本编程-结构化命令2-for命令
    sscanf解析复杂字符串,双引号通配符的使用问题
    shell脚本编程-结构化命令1-分支语句
    shell脚本编程基础
    linux系统管理的基本命令2
    linux系统管理的基本命令
    redis
    Eclipse启动报错
    java斗地主发牌源码
  • 原文地址:https://www.cnblogs.com/sjqq/p/7413725.html
Copyright © 2011-2022 走看看