Permalink
Browse files

fix: pro-IUAPDESIGN-242:广信中移动项目:grid提供数据改变之前进行判断是否修改的接口

  • Loading branch information...
liuyk
liuyk committed Nov 2, 2016
1 parent f2ec5ad commit 7246dbcb3883c804da444f83196f45c34632a069
Showing with 36 additions and 7 deletions.
  1. +13 −0 js/dataTable/events.js
  2. +8 −7 js/dataTable/indexDataTable.js
  3. +15 −0 js/dataTable/row-data.js
View
@@ -94,6 +94,18 @@ const trigger = function (name) {
return this;
}
const triggerReturn = function(name){
name = name.toLowerCase()
if (!this._events || !this._events[name]) return this;
var args = Array.prototype.slice.call(arguments, 1);
var events = this._events[name];
var flag = true;
for (var i = 0, count = events.length; i < count; i++) {
flag = flag && events[i].callback.apply(this, args);
}
return flag;
}
const getEvent = function (name) {
name = name.toLowerCase()
@@ -106,5 +118,6 @@ export {
off,
one,
trigger,
triggerReturn,
getEvent
}
@@ -168,6 +168,7 @@ import {
off,
one,
trigger,
triggerReturn,
getEvent
} from './events';
@@ -176,12 +177,6 @@ class DataTable{
constructor(options){
// IE9下转化之后的代码有问题,无法获得superClass方法
// super();
this.on = on;
this.off = off;
this.one = one;
this.trigger = trigger;
this.getEvent = getEvent;
options = options || {};
this.id = options['id'];
this.strict = options['strict'] || false;
@@ -221,7 +216,12 @@ class DataTable{
}
}
DataTable.prototype.on = on;
DataTable.prototype.off = off;
DataTable.prototype.one = one;
DataTable.prototype.trigger = trigger;
DataTable.prototype.triggerReturn = triggerReturn;
DataTable.prototype.getEvent = getEvent;
//copyRow
DataTable.prototype.copyRow= copyRow;
DataTable.prototype.copyRows= copyRows;
@@ -372,6 +372,7 @@ DataTable.ON_ROW_UNSELECT = 'unSelect'
DataTable.ON_ROW_ALLSELECT = 'allSelect'
DataTable.ON_ROW_ALLUNSELECT = 'allUnselect'
DataTable.ON_VALUE_CHANGE = 'valueChange'
DataTable.ON_BEFORE_VALUE_CHANGE = 'beforeValueCHange'
DataTable.ON_CURRENT_VALUE_CHANGE = 'currentValueChange' //当前行变化
// DataTable.ON_AFTER_VALUE_CHANGE = 'afterValueChange'
// DataTable.ON_ADD_ROW = 'addRow'
View
@@ -9,6 +9,7 @@ import {isArray} from 'tinper-sparrow/js/util';
*设置row中某一列的值
*/
const setValue = function (fieldName, value, ctx, options) {
if (arguments.length === 1){
value = fieldName;
fieldName = '$data';
@@ -17,6 +18,20 @@ const setValue = function (fieldName, value, ctx, options) {
if(typeof oldValue == 'undefined' || oldValue === null)
oldValue = ''
if (eq(oldValue, value)) return;
var event = {
eventType: 'dataTableEvent',
dataTable: this.parent.id,
rowId: this.rowId,
field: fieldName,
oldValue: oldValue,
newValue: value,
ctx: ctx || ""
}
var flag = this.parent.triggerReturn(DataTable.ON_BEFORE_VALUE_CHANGE, event);
if(!flag){
_triggerChange(this, fieldName, oldValue, ctx);
return;
}
_getField(this, fieldName)['value'] = value;
_triggerChange(this, fieldName, oldValue, ctx);
}

0 comments on commit 7246dbc

Please sign in to comment.