Permalink
Browse files

fix: tab键考虑onBeforeEditFun处理

  • Loading branch information...
liuyk
liuyk committed Nov 18, 2016
1 parent a95c9b3 commit fbbf509fa3c980cf7c85401aa545caa5c4b0d595
Showing with 71 additions and 43 deletions.
  1. +33 −19 dist/js/u-grid.js
  2. +5 −5 dist/js/u-grid.min.js
  3. +33 −19 js/re_gridCompEdit.js
View
@@ -5093,33 +5093,34 @@
var colIndex = $td.index();
if (this.options.editable && (this.eidtRowIndex != index || this.options.editType == 'default' && this.editColIndex != colIndex)) {
this.editClose();
if (typeof this.options.onBeforeEditFun == 'function') {
var obj = {};
obj.gridObj = this;
obj.rowObj = this.dataSourceObj.rows[index];
obj.rowIndex = index;
obj.colIndex = colIndex;
obj.$tr = $tr;
obj.e = e;
if (!this.options.onBeforeEditFun(obj)) {
if (this.eidtRowIndex != -1) {
this.editClose();
}
return;
}
}
this.editRowFun($tr, colIndex);
}
};
var editRowFun = function editRowFun($tr, colIndex) {
var index = this.getTrIndex($tr);
if (typeof this.options.onBeforeEditFun == 'function') {
var obj = {};
obj.gridObj = this;
obj.rowObj = this.dataSourceObj.rows[index];
obj.rowIndex = index;
obj.colIndex = colIndex;
obj.$tr = $tr;
if (!this.options.onBeforeEditFun(obj)) {
if (this.eidtRowIndex != -1) {
this.editClose();
}
return;
}
}
if (this.eidtRowIndex != -1) {
this.editClose();
}
var index = typeof $tr === 'number' ? $tr : this.getTrIndex($tr);
this.eidtRowIndex = index;
this.editColIndex = colIndex;
this.editRow($tr, colIndex);
return true;
};
var editRowIndexFun = function editRowIndexFun(i) {
if (this.eidtRowIndex != -1) {
@@ -5466,16 +5467,29 @@
}
}
colIndex = _getNextEditColIndex(this, colIndex);
colIndex = _getNextEditColIndex(this, colIndex, $tr);
this.editRowFun($tr, colIndex);
};
var _getNextEditColIndex = function _getNextEditColIndex(gridObj, nowIndex) {
var _getNextEditColIndex = function _getNextEditColIndex(gridObj, nowIndex, $tr) {
// 如果下一列为隐藏/不可修改/复选框则跳到下一个
var colIndex = -1;
var column = gridObj.gridCompColumnArr[nowIndex];
if (!column.options.visible || !column.options.editable) {
colIndex = _getNextEditColIndex(gridObj, nowIndex + 1);
var beforeFlag = true;
var index = gridObj.getTrIndex($tr);
if (typeof gridObj.options.onBeforeEditFun == 'function') {
var obj = {};
obj.gridObj = gridObj;
obj.rowObj = gridObj.dataSourceObj.rows[index];
obj.rowIndex = index;
obj.colIndex = nowIndex;
obj.$tr = $tr;
if (!gridObj.options.onBeforeEditFun(obj)) {
beforeFlag = false;
}
}
if (!column.options.visible || !column.options.editable || !beforeFlag) {
colIndex = _getNextEditColIndex(gridObj, nowIndex + 1, $tr);
} else {
colIndex = nowIndex;
}
Oops, something went wrong.

0 comments on commit fbbf509

Please sign in to comment.