Permalink
Browse files

fix: 增加机制datatable通知grid时不再反向通知datatable

  • Loading branch information...
1 parent 60c072b commit c14321c21781a69b4f2a7818efc9ca805e218dbd liuyk committed Nov 2, 2016
Showing with 35 additions and 7 deletions.
  1. +35 −7 js/component/keroa-grid.js
@@ -542,7 +542,7 @@ var GridAdapter = BaseAdapter.extend({
}
};
this.dataTable.on(DataTable.ON_ROW_SELECT, function(event) {
-
+ // oThis.silence = true;
var gridSelectRows = [];
$.each(oThis.grid.getSelectRows(),function(){
gridSelectRows.push(this);
@@ -574,18 +574,22 @@ var GridAdapter = BaseAdapter.extend({
}
}
});
-
+ // oThis.silence = false;
});
//全选
this.dataTable.on(DataTable.ON_ROW_ALLSELECT, function(event) {
- oThis.grid.setAllRowSelect()
+ // oThis.silence = true;
+ oThis.grid.setAllRowSelect();
+ // oThis.silence = false;
});
//全返选
this.dataTable.on(DataTable.ON_ROW_ALLUNSELECT, function(event) {
- oThis.grid.setAllRowUnSelect()
+ // oThis.silence = true;
+ oThis.grid.setAllRowUnSelect();
+ // oThis.silence = false;
});
// 反选
@@ -601,6 +605,7 @@ var GridAdapter = BaseAdapter.extend({
}
};
this.dataTable.on(DataTable.ON_ROW_UNSELECT, function(event) {
+ // oThis.silence = true;
$.each(event.rowIds, function() {
var index = oThis.grid.getRowIndexByValue('$_#_@_id',this);
var unSelectFlag = true;
@@ -615,6 +620,7 @@ var GridAdapter = BaseAdapter.extend({
}
}
});
+ // oThis.silence = false;
});
var onRowFocusFun = this.gridOptions.onRowFocus;
@@ -636,6 +642,7 @@ var GridAdapter = BaseAdapter.extend({
}
};
this.dataTable.on(DataTable.ON_ROW_FOCUS, function(event) {
+ // oThis.silence = true;
/*index转化为grid的index*/
var index = oThis.grid.getRowIndexByValue('$_#_@_id',event.rowId);
@@ -647,6 +654,7 @@ var GridAdapter = BaseAdapter.extend({
oThis.dataTable.setRowUnFocus(oThis.dataTable.getIndexByRowId(event.rowId));
}
}
+ // oThis.silence = false;
});
// 反focus
@@ -662,6 +670,7 @@ var GridAdapter = BaseAdapter.extend({
}
};
this.dataTable.on(DataTable.ON_ROW_UNFOCUS, function(event) {
+ // oThis.silence = true;
var index = oThis.grid.getRowIndexByValue('$_#_@_id',event.rowId);
var unFocusFlag = true;
if(index > -1){
@@ -670,6 +679,7 @@ var GridAdapter = BaseAdapter.extend({
oThis.dataTable.setRowFocus(oThis.dataTable.getIndexByRowId(event.rowId));
}
}
+ // oThis.silence = false;
});
// 增行,只考虑viewModel传入grid
@@ -681,6 +691,7 @@ var GridAdapter = BaseAdapter.extend({
// }
// };
this.dataTable.on(DataTable.ON_INSERT, function(event) {
+ // oThis.silence = true;
var gridRows = new Array();
$.each(event.rows,function(){
var row = this.data;
@@ -693,9 +704,11 @@ var GridAdapter = BaseAdapter.extend({
gridRows.push(gridRow);
})
oThis.grid.addRows(gridRows,event.index);
+ // oThis.silence = false;
});
this.dataTable.on(DataTable.ON_UPDATE, function(event) {
+ // oThis.silence = true;
$.each(event.rows,function(){
var row = this.data;
var id = this.rowId;
@@ -707,11 +720,11 @@ var GridAdapter = BaseAdapter.extend({
var index = oThis.grid.getRowIndexByValue('$_#_@_id',id);
oThis.grid.updateRow(index,gridRow);
})
-
+ // oThis.silence = false;
});
this.dataTable.on(DataTable.ON_VALUE_CHANGE, function(obj) {
-
+ oThis.silence = true;
var id = obj.rowId;
var index = oThis.grid.getRowIndexByValue('$_#_@_id',id);
if(index == -1) {
@@ -721,6 +734,7 @@ var GridAdapter = BaseAdapter.extend({
var value = obj.newValue;
oThis.grid.updateValueAt(index,field,value);
//oThis.grid.editClose();
+ oThis.silence = false;
});
this.gridOptions.onRowDelete = function(obj){
@@ -731,17 +745,21 @@ var GridAdapter = BaseAdapter.extend({
}
};
this.dataTable.on(DataTable.ON_DELETE, function(event) {
+ // oThis.silence = true;
/*index转化为grid的index*/
var gridIndexs = new Array();
$.each(event.rowIds, function() {
var index = oThis.grid.getRowIndexByValue('$_#_@_id',this);
gridIndexs.push(index);
});
oThis.grid.deleteRows(gridIndexs);
+ // oThis.silence = false;
});
this.dataTable.on(DataTable.ON_DELETE_ALL, function(event) {
- oThis.grid.setDataSource({})
+ // oThis.silence = true;
+ oThis.grid.setDataSource({});
+ // oThis.silence = false;
});
// 数据改变
@@ -763,6 +781,7 @@ var GridAdapter = BaseAdapter.extend({
}
};
this.dataTable.on('valueChange', function(event) {
+ // oThis.silence = true;
var field = event.field,
rowId = event.rowId,
oldValue = event.oldValue,
@@ -771,9 +790,11 @@ var GridAdapter = BaseAdapter.extend({
if(rowIndex > -1){
oThis.grid.updateValueAt(rowIndex,field,newValue);
}
+ // oThis.silence = false;
});
// 加载数据,只考虑viewModel传入grid
this.dataTable.on(DataTable.ON_LOAD, function(data) {
+ // oThis.silence = true;
if(data.length > 0){
var values = new Array();
@@ -792,12 +813,16 @@ var GridAdapter = BaseAdapter.extend({
dataSource['values'] = values;
oThis.grid.setDataSource(dataSource);
}
+ // oThis.silence = false;
});
this.dataTable.on(DataTable.ON_ENABLE_CHANGE, function(enable) {
+ // oThis.silence = true;
oThis.grid.setEditable(enable.enable);
+ // oThis.silence = false;
});
this.dataTable.on(DataTable.ON_ROW_META_CHANGE, function(event){
+ // oThis.silence = true;
var field = event.field,
meta = event.meta,
row = event.row,
@@ -819,14 +844,17 @@ var GridAdapter = BaseAdapter.extend({
oThis.grid.updateValueAt(index,field,value,true);
}
+ // oThis.silence = false;
})
this.dataTable.on(DataTable.ON_META_CHANGE, function(event){
+ // oThis.silence = true;
var field = event.field
var meta = event.meta
if (meta == 'precision'){
oThis.grid.renderTypeFun({field:field})
}
+ // oThis.silence = false;
})
this.gridOptions.transMap = {

0 comments on commit c14321c

Please sign in to comment.