11import utils from '../../src/utils/utils.js'
2+ import { hasClass , addClass , removeClass } from '../../src/utils/dom.js'
3+
24export default {
35
46 methods : {
57 // cell edit
6- cellEdit ( e , callback , rowIndex , rowData , field ) {
8+ cellEdit ( e , callback , rowIndex , rowData , field ) {
79
810 let target = e . target ,
911 self = this ,
@@ -18,15 +20,15 @@ export default {
1820 target = target . parentNode ;
1921 }
2022
21- if ( target . classList . contains ( 'cell-editing' ) ) {
23+ if ( hasClass ( target , 'cell-editing' ) ) {
2224 return false
2325 }
2426
25- target . classList . add ( 'cell-editing' ) ;
27+ addClass ( target , 'cell-editing' ) ;
2628
2729 oldVal = target . innerText ;
2830
29- if ( target . style . textAlign ) {
31+ if ( target . style . textAlign ) {
3032
3133 textAlign = target . style . textAlign ;
3234 }
@@ -50,45 +52,45 @@ export default {
5052
5153 actionFun = function ( e ) {
5254
53- if ( typeof e . keyCode === 'undefined' || e . keyCode == 13 ) {
54-
55+ if ( typeof e . keyCode === 'undefined' || e . keyCode === 0 || e . keyCode == 13 ) {
5556
56- if ( target . classList . contains ( 'cell-editing' ) ) {
57- target . classList . remove ( 'cell-editing' ) ;
57+ if ( hasClass ( target , 'cell-editing' ) ) {
5858
59- } else {
59+ removeClass ( target , 'cell-editing' ) ;
60+ } else {
6061 return false ;
6162 }
6263
63- formatterVal = self . cellEditFormatter && self . cellEditFormatter ( this . value , oldVal , rowIndex , rowData , field ) ;
64+ formatterVal = self . cellEditFormatter && self . cellEditFormatter ( editInput . value , oldVal , rowIndex , rowData , field ) ;
6465
65- target . innerHTML = formatterVal && formatterVal . length > 0 ? formatterVal :this . value ;
66+ target . innerHTML = formatterVal && formatterVal . length > 0 ? formatterVal : editInput . value ;
6667
67- callback ( this . value , oldVal )
68+ // fixed this.value bug in IE9
69+ callback ( editInput . value , oldVal )
6870
6971 utils . unbind ( editInput , 'blur' , actionFun ) ;
70- utils . unbind ( editInput , 'keydown' , actionFun ) ;
72+ utils . unbind ( editInput , 'keydown' , actionFun ) ;
7173 }
7274 } ;
7375
7476
7577 utils . bind ( editInput , 'blur' , actionFun ) ;
76- utils . bind ( editInput , 'keydown' , actionFun ) ;
78+ utils . bind ( editInput , 'keydown' , actionFun ) ;
7779 } ,
7880
7981 // 单元格点击
80- cellEditClick ( e , isEdit , rowData , field , rowIndex ) {
82+ cellEditClick ( e , isEdit , rowData , field , rowIndex ) {
8183
82- if ( isEdit ) {
84+ if ( isEdit ) {
8385
8486 let self = this ;
8587 // 单元格内容变化后的回调
86- let onCellEditCallBack = function ( newValue , oldVal ) {
88+ let onCellEditCallBack = function ( newValue , oldVal ) {
8789
88- self . cellEditDone ( newValue , oldVal , rowIndex , rowData , field ) ;
90+ self . cellEditDone ( newValue , oldVal , rowIndex , rowData , field ) ;
8991 }
9092
91- this . cellEdit ( e , onCellEditCallBack , rowIndex , rowData , field )
93+ this . cellEdit ( e , onCellEditCallBack , rowIndex , rowData , field )
9294 }
9395 } ,
9496 }
0 commit comments