Permalink
Browse files

feat: resetAllValue增加判断状态,如果为新增则删除此数据,如果为删除则新增此数据,如果为更新则还原数据

  • Loading branch information...
LiuYueKai committed Apr 13, 2017
1 parent f3d0d77 commit b8683244e696abc1a5a8c0dafe8ad10b5b2cc7c9
Showing with 27 additions and 1 deletion.
  1. +27 −1 src/data.js
@@ -171,7 +171,21 @@ const setValue = function(fieldName, value, row, ctx) {
const resetAllValue = function() {
var rows = this.rows();
for (var i = 0; i < rows.length; i++) {
var row = rows[i];
if(row.status == Row.STATUS.NEW){
this.setRowsDelete(row);
}else if(row.status == Row.STATUS.FALSE_DELETE){
row.status = Row.STATUS.NORMAL;
var rows = [row];
this.trigger(DataTable.ON_INSERT, {
index: 0,
rows: rows
})
}else if(row.status == Row.STATUS.UPDATE){
row.status = Row.STATUS.NORMAL;
rows[i].resetValue();
}

}
}

@@ -180,7 +194,19 @@ const resetAllValue = function() {
* @param {u.row} row 需要重置数据的row对象
*/
const resetValueByRow = function(row) {
row.resetValue();
if(row.status == Row.STATUS.NEW){
this.setRowsDelete(row);
}else if(row.status == Row.STATUS.FALSE_DELETE){
row.status = Row.STATUS.NORMAL;
var rows = [row];
this.trigger(DataTable.ON_INSERT, {
index: 0,
rows: rows
})
}else if(row.status == Row.STATUS.UPDATE){
row.status = Row.STATUS.NORMAL;
rows[i].resetValue();
}

}

0 comments on commit b868324

Please sign in to comment.