有时候在行编辑的时候,一个编辑框的值要根据其它编辑框的值进行变化,那么能够经过在开启编辑时,找到特定的Editor,为其添加事件工具
// 绑定事件, index为当前编辑行测试
var editors = $('#staffLogDetailGrid').datagrid('getEditors', index); //得到当前行的编辑对象ui
console.info(editors[5]); //editor[5]表示第五列这个控件spa
var sfgzEditor = editors[5];.net
sfgzEditor.target.bind('change',function () {对象
console.info("111");事件
console.info(sfgzEditor.target.val()); //sfgzEditor.target就是操做第五列控件对象ci
});get
以上的edit类型是: 'validatebox',以下所示;input
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绑定事件了;