EasyUI中datagrid的行編輯模式中,找到特定的Editor,並為其添加事件


有時候在行編輯的時候,一個編輯框的值要根據其它編輯框的值進行變化,那么可以通過在開啟編輯時,找到特定的Editor,為其添加事件

 

// 綁定事件, index為當前編輯行

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

console.info(editors[5]);

var sfgzEditor = editors[5];

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

    console.info("111");

    console.info(sfgzEditor.target.val());

});

以上的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綁定事件了;

http://blog.csdn.net/d7011800/article/details/8692635

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM