|
|
|
|
|
|
|
|
|
define(function (require, exports, module) {
|
|
|
|
|
var editorHandler = require('../views/editors/handler');
|
|
|
|
|
|
|
|
|
|
function GridAdapter(id, args, pageId) {
|
|
|
|
|
args = _.clone(args);
|
|
|
|
|
this.id = id;
|
|
|
|
|
this.pageId = pageId;
|
|
|
|
|
this.data = {
|
|
|
|
|
columns: [],
|
|
|
|
|
rows: []
|
|
|
|
|
};
|
|
|
|
|
this.vmodel = {};
|
|
|
|
|
this.selectedRows = [];
|
|
|
|
|
this.isGroupHeader = false;
|
|
|
|
|
|
|
|
|
|
args = args || {};
|
|
|
|
|
|
|
|
|
|
_init(this, args);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function _init(self, args) {
|
|
|
|
|
|
|
|
|
|
_initOpts(self, args);
|
|
|
|
|
|
|
|
|
|
_initActions(self, args);
|
|
|
|
|
|
|
|
|
|
self.isGroupHeader = isGroupHeader(args.data.columns);
|
|
|
|
|
|
|
|
|
|
//数据源专属操作
|
|
|
|
|
if (args.data && args.data.isDataSource) {
|
|
|
|
|
_initDs(self, args);
|
|
|
|
|
} else {
|
|
|
|
|
if (self.isGroupHeader) {
|
|
|
|
|
self.data.columns = treeTanversal(flatten2Tree(columns2Flatten(args.data.columns)));
|
|
|
|
|
} else {
|
|
|
|
|
self.data.columns = _setColumns(self, args.data.columns);
|
|
|
|
|
}
|
|
|
|
|
self.data.rows = args.data.rows;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function _initOpts(self, args) {
|
|
|
|
|
var opts = {
|
|
|
|
|
autoEdit: true,
|
|
|
|
|
editable: false,
|
|
|
|
|
pageSize: -1,
|
|
|
|
|
pagenum: 0,
|
|
|
|
|
totalRows: -1,
|
|
|
|
|
enableAddRow: false,
|
|
|
|
|
enableCellNavigation: true,
|
|
|
|
|
defaultColumnWidth: 100,
|
|
|
|
|
enableColumnRecorder: true,
|
|
|
|
|
dataItemColumnValueExtractor: function (item, columnDef) {
|
|
|
|
|
if (item && item.getColumnText) {
|
|
|
|
|
return item.getColumnText(columnDef.field);
|
|
|
|
|
}
|
|
|
|
|
return item[columnDef.field];
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (args.opts) {
|
|
|
|
|
self.opts = _.extend(opts, args.opts);
|
|
|
|
|
} else {
|
|
|
|
|
self.opts = opts;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//分页信息设置
|
|
|
|
|
if (args.data && args.data.isDataSource) {
|
|
|
|
|
args.data.setPageSize(self.opts.pageSize);
|
|
|
|
|
args.data.setPagenum(self.opts.pagenum);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function _initActions(self, _args) {
|
|
|
|
|
self.actions = {
|
|
|
|
|
onClick: function (e, args) {
|
|
|
|
|
if (_args.actions && typeof _args.actions.onClick == 'function') {
|
|
|
|
|
_args.actions.onClick(e, args);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
//grid中删除整行按钮的点击
|
|
|
|
|
onColumndeleteButtonClick: function (row) {
|
|
|
|
|
if (_args.actions && typeof _args.actions.onColumndeleteButtonClick == 'function') {
|
|
|
|
|
_args.actions.onColumndeleteButtonClick(row);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
//点击grid中cell里按钮的方法
|
|
|
|
|
onGridCellClick: function (object, row) {
|
|
|
|
|
if (_args.actions && typeof _args.actions.onGridCellClick == 'function') {
|
|
|
|
|
_args.actions.onGridCellClick(object, row);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onDblClick: function (e, args) {
|
|
|
|
|
if (_args.actions && typeof _args.actions.onDblClick == 'function') {
|
|
|
|
|
_args.actions.onDblClick(e, args);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onRClick: function (e, args) {
|
|
|
|
|
self.onRClick(e, args);
|
|
|
|
|
if (_args.actions && typeof _args.actions.onRClick == 'function') {
|
|
|
|
|
_args.actions.onRClick(e, args);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onBeforeEditCell: function (e, args) {
|
|
|
|
|
if (self.dataSrc && !self.dataSrc.allowEdit) return false;
|
|
|
|
|
return self.onBeforeEditCell(e, args);
|
|
|
|
|
},
|
|
|
|
|
onActiveCellChanged: function (e, args) {
|
|
|
|
|
self.onActiveCellChanged(e, args);
|
|
|
|
|
},
|
|
|
|
|
onBeforeActiveCellChanged: function (e, args) {
|
|
|
|
|
return self.onBeforeActiveCellChanged(e, args)
|
|
|
|
|
},
|
|
|
|
|
onSelectedRowsChanged: function (e, args) {
|
|
|
|
|
self.onSelectedRowsChanged(e, args);
|
|
|
|
|
if (_args.actions && typeof _args.actions.onSelectedRowsChanged == 'function') {
|
|
|
|
|
_args.actions.onSelectedRowsChanged(e, args);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onSortClicked: function (field, asc) {
|
|
|
|
|
if (_args.actions && typeof _args.actions.onSortClicked == 'function') {
|
|
|
|
|
_args.actions.onSortClicked(field, asc);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onAddNewRow: function (e, args) {
|
|
|
|
|
if (typeof self.onAddNewRow == 'function') {
|
|
|
|
|
self.onAddNewRow(e, args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_args.actions && typeof _args.actions.onAddNewRow == 'function') {
|
|
|
|
|
_args.actions.onAddNewRow(e, args);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onRowCountChanged: function (e, args) {
|
|
|
|
|
self.onRowCountChanged(e, args);
|
|
|
|
|
},
|
|
|
|
|
onRowsChanged: function (e, args) {
|
|
|
|
|
self.onRowsChanged(e, args);
|
|
|
|
|
},
|
|
|
|
|
onPagingInfoChanged: function (e, args) {
|
|
|
|
|
|
|
|
|
|
if (_args.actions && typeof _args.actions.onPagingInfoChanged === 'function') {
|
|
|
|
|
_args.actions.onPagingInfoChanged(e, args);
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
self.onPagingInfoChanged(e, args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
onKeyDown: function (e, args) {
|
|
|
|
|
if (e.ctrlKey && (e.which == 46 || e.which == 110)) {
|
|
|
|
|
var grid = args.grid;
|
|
|
|
|
var editable = grid.getOptions().editable;
|
|
|
|
|
if (!editable || !self.dataSrc.allowDel) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var dataRow = grid.getDataItem(args.row);
|
|
|
|
|
if (dataRow && dataRow.isDataRow) {
|
|
|
|
|
dataRow.delete(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (e.ctrlKey && e.which == 45) {
|
|
|
|
|
var grid = args.grid;
|
|
|
|
|
var editable = grid.getOptions().editable;
|
|
|
|
|
if (!editable || !self.dataSrc.allowInsert) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (self.dataSrc.currentRow && self.dataSrc.currentRow.validate()) {
|
|
|
|
|
self.dataSrc.addRow();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onActiveFirstCell: function () {
|
|
|
|
|
if (_args.actions && typeof _args.actions.onActiveFirstCell == 'function') {
|
|
|
|
|
_args.actions.onActiveFirstCell();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var grid = self.vmodel.$grid;
|
|
|
|
|
var nowEditor;
|
|
|
|
|
if (grid.getColumns().length) {
|
|
|
|
|
for (i = 0; i < grid.getColumns().length; i++) {
|
|
|
|
|
grid.setActiveCell(0, i);
|
|
|
|
|
grid.editActiveCell();
|
|
|
|
|
if (grid.getCellEditor()) {
|
|
|
|
|
nowEditor = grid.getCellEditor();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
nowEditor.focus();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 参数actions覆盖adpter actions,不知道原来为什么被注释掉
|
|
|
|
|
// if (_args.actions) {
|
|
|
|
|
// _.extend(self.actions, _args.actions);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function _initDs(self, args) {
|
|
|
|
|
self.dataSrc = args.data;
|
|
|
|
|
self.opts.editable = self.opts.editable ? true : self.dataSrc.getEditable();
|
|
|
|
|
self.opts.enableAddRow = self.dataSrc.allowInsert && self.opts.editable;
|
|
|
|
|
|
|
|
|
|
self.dataSrc.on('onCollectChanged', function (ds, args) {
|
|
|
|
|
if (args.action != Store.Enums.CollectionChangedAction.REPLACE) {
|
|
|
|
|
self.setData(ds.rows);
|
|
|
|
|
|
|
|
|
|
// 分页以及排序情况下不必重置排序
|
|
|
|
|
if (ds.isMaster || (!ds.isMaster && !ds.detailPageOrderList)) {
|
|
|
|
|
self.resetSort();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (self.dataSrc.getPagenum() == 0) {
|
|
|
|
|
self.setPagingOptions({ pageNum: self.dataSrc.getPagenum() }, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//通常只有reject操作才会出现该现象
|
|
|
|
|
if (args.action == Store.Enums.CollectionChangedAction.RESET && ds.currentRow !== null) {
|
|
|
|
|
_setGridCurrentRow(self, ds.currentRow, 0);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (self.vmodel.$grid) {
|
|
|
|
|
var grid = self.vmodel.$grid;
|
|
|
|
|
var row = self.vmodel.$dataView.getRowById(args.row['$id']);
|
|
|
|
|
grid.updateRow(row);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
self.afterDataSrcLoadData();
|
|
|
|
|
}, self);
|
|
|
|
|
|
|
|
|
|
self.dataSrc.on('onValueChanged', function (ds, e) {
|
|
|
|
|
if (self.vmodel.$grid) {
|
|
|
|
|
var grid = self.vmodel.$grid;
|
|
|
|
|
//var idx = self.vmodel.$dataView.getIdxById(e.row['$id']);
|
|
|
|
|
var row = self.vmodel.$dataView.getRowById(e.row['$id']);
|
|
|
|
|
var col = grid.getColumnIndex(e.col.fieldName);
|
|
|
|
|
grid.updateCell(row, col);
|
|
|
|
|
//grid.resizeCanvas();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// self.afterDataSrcLoadData();
|
|
|
|
|
}, self);
|
|
|
|
|
self.dataSrc.on('onPropertyChanged', function (ds, e) {
|
|
|
|
|
if (e.propertyName == 'Editable') {
|
|
|
|
|
self.setEditable(ds.getEditable());
|
|
|
|
|
}
|
|
|
|
|
}, self);
|
|
|
|
|
|
|
|
|
|
self.dataSrc.on('onCurrentChanged', function (ds, e) {
|
|
|
|
|
_setGridCurrentRow(self, e.newRow);
|
|
|
|
|
}, self);
|
|
|
|
|
|
|
|
|
|
self.dataSrc.on('commitEdit', function (ds, e) {
|
|
|
|
|
e.isCancel = !self.commitEditor();
|
|
|
|
|
//在beforeSave前移除空行
|
|
|
|
|
if (!e.isCancel) {
|
|
|
|
|
self.dataSrc.removeEmptyRow();
|
|
|
|
|
}
|
|
|
|
|
}, self);
|
|
|
|
|
|
|
|
|
|
self.dataSrc.on('onAfterDataSrcLoadData', function (ds, e) {
|
|
|
|
|
self.afterDataSrcLoadData();
|
|
|
|
|
self.resizeGrid();
|
|
|
|
|
}, self);
|
|
|
|
|
|
|
|
|
|
self.dataSrc.on('onAfterDataSrcSave', function (ds, e) {
|
|
|
|
|
self.afterDataSrcLoadData();
|
|
|
|
|
}, self);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
args.data = {
|
|
|
|
|
columns: _setColumns(self, self.dataSrc.columns),
|
|
|
|
|
rows: self.dataSrc.rows
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.data = args.data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//提供的方法实现
|
|
|
|
|
|
|
|
|
|
function _setGridCurrentRow(self, dataRow, cellCol) {
|
|
|
|
|
if (self.vmodel.$dataView && self.vmodel.$grid) {
|
|
|
|
|
var newCell = null
|
|
|
|
|
if (!dataRow) {
|
|
|
|
|
self.vmodel.$grid.resetActiveCell()
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var index = self.vmodel.$dataView.getRowById(dataRow.$id);
|
|
|
|
|
var oldActiveCell = self.vmodel.$grid.getActiveCell();
|
|
|
|
|
if (oldActiveCell && oldActiveCell.row == index) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
newCell = {
|
|
|
|
|
row: index > -1 ? index : 0,
|
|
|
|
|
col: oldActiveCell ? oldActiveCell.cell : 0
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (cellCol !== undefined) {
|
|
|
|
|
newCell.col = cellCol;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (self.vmodel.$grid.getEditorLock()) {
|
|
|
|
|
self.vmodel.$grid.getEditorLock().cancelCurrentEdit()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self.vmodel.$grid.setActiveCell(newCell.row, newCell.col);
|
|
|
|
|
// self.vmodel.$grid.scrollRowIntoView(newCell.row, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 设置网格列的属性
|
|
|
|
|
* @param {[type]} gridColumn [description]
|
|
|
|
|
* @param {[type]} dataColumn [description]
|
|
|
|
|
*/
|
|
|
|
|
function _setColumnOptions(gridColumn, dataColumn) {
|
|
|
|
|
|
|
|
|
|
gridColumn.id = dataColumn.fieldName;
|
|
|
|
|
gridColumn.sortable = true;
|
|
|
|
|
gridColumn.field = dataColumn.fieldName;
|
|
|
|
|
gridColumn.width = parseInt(dataColumn.headerWidth) * 12;
|
|
|
|
|
if (gridColumn.width < 56) {
|
|
|
|
|
gridColumn.width = 56;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gridColumn.name = dataColumn.dispName;
|
|
|
|
|
gridColumn.isCalc = dataColumn.isCalc;
|
|
|
|
|
gridColumn.formatter = dataColumn.getFormatter();
|
|
|
|
|
gridColumn.isEditable = dataColumn.isEditable;
|
|
|
|
|
gridColumn.dataColumn = dataColumn;
|
|
|
|
|
gridColumn.cannotTriggerInsert = !dataColumn.isEditable;
|
|
|
|
|
//2015-10-08添加这个属性,用来判断时是否可以编辑。
|
|
|
|
|
gridColumn.isReadonly = !dataColumn.isEditable;
|
|
|
|
|
if (!dataColumn.isEditable) {
|
|
|
|
|
gridColumn.cssClass = 'column-un-editable';
|
|
|
|
|
} else {
|
|
|
|
|
gridColumn.cssClass = 'column-un-edit';
|
|
|
|
|
}
|
|
|
|
|
if (dataColumn.editStyle === Store.Enums.EditStyle.DECIMAL) {
|
|
|
|
|
gridColumn.cssClass = gridColumn.cssClass ? gridColumn.cssClass + ' decimal-column-show' : 'decimal-column-show';
|
|
|
|
|
}
|
|
|
|
|
gridColumn.validator = function (item, newValue) {
|
|
|
|
|
var result = {};
|
|
|
|
|
if (dataColumn) {
|
|
|
|
|
result.valid = dataColumn.validator(item, newValue);
|
|
|
|
|
if (!result.valid) {
|
|
|
|
|
result.msg = item.getColumnError(dataColumn.fieldName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
gridColumn.editor = editorHandler.getEditor(dataColumn.editStyle);
|
|
|
|
|
if (dataColumn.dataSrc) {
|
|
|
|
|
gridColumn.cache = (dataColumn.dataSrc.datasetName + '_' + dataColumn.fieldName).toLowerCase();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function _setColumns(self, dataColumns) {
|
|
|
|
|
var columns = [];
|
|
|
|
|
var orderCols = [];
|
|
|
|
|
var sortedColumns = _.sortBy(dataColumns, 'dispIndex');
|
|
|
|
|
var pageIdArray = null;
|
|
|
|
|
if (self.opts.pageId) {
|
|
|
|
|
pageIdArray = self.opts.pageId.split(',');
|
|
|
|
|
for (var i = 0; i < pageIdArray.length; i++) {
|
|
|
|
|
orderCols = orderCols.concat(_.where(dataColumns, {
|
|
|
|
|
'pageId': parseInt(pageIdArray[i])
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
orderCols = _.sortBy(orderCols, 'dispIndex');
|
|
|
|
|
} else {
|
|
|
|
|
orderCols = sortedColumns;
|
|
|
|
|
}
|
|
|
|
|
for (var i = 0; i < orderCols.length; i++) {
|
|
|
|
|
var column = {};
|
|
|
|
|
var item = orderCols[i];
|
|
|
|
|
if ((item.procParaType == Store.Enums.ProcParaType.NONE || !item.procParaType)
|
|
|
|
|
&& (item.dispPosition == '0' || item.dispPosition == '1')) {
|
|
|
|
|
_setColumnOptions(column, item);
|
|
|
|
|
columns.push(column);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (self.isGroupHeader) {
|
|
|
|
|
columns = treeTanversal(flatten2Tree(columns2Flatten(columns)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return columns;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function columns2Flatten(columns) {
|
|
|
|
|
var array = [];
|
|
|
|
|
for (var i = 0; i < columns.length; i++) {
|
|
|
|
|
var names = columns[i].name.split('|');
|
|
|
|
|
var fields = columns[i].field.split('|');
|
|
|
|
|
if (fields.length > 1) { //分组
|
|
|
|
|
for (var j = 0; j < fields.length; j++) {
|
|
|
|
|
var column = {};
|
|
|
|
|
column.name = names[j];
|
|
|
|
|
column.sid = fields[j];
|
|
|
|
|
column.headerCssClass = 'text-center';
|
|
|
|
|
if (j == 0) {
|
|
|
|
|
column.pid = 0;
|
|
|
|
|
} else {
|
|
|
|
|
column.pid = fields[j - 1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (j < (fields.length - 1)) {
|
|
|
|
|
column.id = fields[0];
|
|
|
|
|
array.push(column);
|
|
|
|
|
} else if (j == (fields.length - 1)) { //末级
|
|
|
|
|
columns[i].name = names[j];
|
|
|
|
|
columns[i].sid = fields[j];
|
|
|
|
|
columns[i].pid = fields[j - 1];
|
|
|
|
|
array.push(columns[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
} else { //无分组
|
|
|
|
|
columns[i].sid = columns[i].id;
|
|
|
|
|
columns[i].pid = 0;
|
|
|
|
|
array.push(columns[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
return array;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function isGroupHeader(columns) {
|
|
|
|
|
for (var i = 0; i < columns.length; i++) {
|
|
|
|
|
if (columns[i].field) {
|
|
|
|
|
var fields = columns[i].field.split('|');
|
|
|
|
|
if (fields.length > 1) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function flatten2Tree(arr) {
|
|
|
|
|
var tree = [],
|
|
|
|
|
mappedArr = {},
|
|
|
|
|
arrElem,
|
|
|
|
|
mappedElem;
|
|
|
|
|
|
|
|
|
|
for (var i = 0, len = arr.length; i < len; i++) {
|
|
|
|
|
arrElem = arr[i];
|
|
|
|
|
mappedArr[arrElem.id] = arrElem;
|
|
|
|
|
mappedArr[arrElem.id]['columns'] = [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (var sid in mappedArr) {
|
|
|
|
|
if (mappedArr.hasOwnProperty(sid)) {
|
|
|
|
|
mappedElem = mappedArr[sid];
|
|
|
|
|
if (mappedElem.pid) {
|
|
|
|
|
mappedArr[mappedElem['pid']]['columns'].push(mappedElem);
|
|
|
|
|
} else {
|
|
|
|
|
tree.push(mappedElem);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return tree;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function treeTanversal(tree) {
|
|
|
|
|
for (var i = 0; i < tree.length; i++) {
|
|
|
|
|
if (tree[i].hasOwnProperty('columns')) {
|
|
|
|
|
if (tree[i].columns.length == 0) {
|
|
|
|
|
var column = _.clone(tree[i]); //JSON.parse(JSON.stringify(tree[i]));
|
|
|
|
|
delete column.columns;
|
|
|
|
|
tree[i].columns.push(column);
|
|
|
|
|
tree[i].name = '';
|
|
|
|
|
delete tree[i].field;
|
|
|
|
|
} else {
|
|
|
|
|
trimArray(tree[i].columns);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return tree;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function trimArray(arr) {
|
|
|
|
|
for (var i = 0; i < arr.length; i++) {
|
|
|
|
|
if (arr[i].hasOwnProperty('columns')) {
|
|
|
|
|
if (arr[i].columns.length == 0) {
|
|
|
|
|
delete arr[i].columns;
|
|
|
|
|
} else {
|
|
|
|
|
trimArray(arr[i].columns);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GridAdapter.prototype.onPagingInfoChanged = function (e, args) {
|
|
|
|
|
var self = this;
|
|
|
|
|
if (Number.isNaN(args.pageNum) || args.pageNum < 0 || args.pageNum == self.dataSrc.getPagenum() || self.dataSrc.getTotalRows() <= 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self.dataSrc.setPagenum(args.pageNum);
|
|
|
|
|
self.dataSrc.search(function () {
|
|
|
|
|
//self.vmodel.$grid.resizeCanvas();
|
|
|
|
|
self.vmodel.$resizeGrid();
|
|
|
|
|
}, {
|
|
|
|
|
reset: false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
var prevPageSize = self.dataSrc._pageSize;
|
|
|
|
|
var prevPageNum = self.dataSrc._pagenum;
|
|
|
|
|
var prevTotalRows = self.dataSrc._totalRows;
|
|
|
|
|
if ((prevPageSize == args.pageSize && prevPageNum == args.pageNum) || (args.totalRows == 0 && args.totalPages == 1)) {
|
|
|
|
|
//DataSurce.clear()触发onCollectChanged引起pageingInfo改变,不作处理
|
|
|
|
|
self.vmodel.$grid.resizeCanvas();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (prevPageSize == -1 && (args.pageSize == 0 || args.pageNum == 0)) {
|
|
|
|
|
self.dataSrc.setPageSize(args.pageSize);
|
|
|
|
|
self.vmodel.$grid.resizeCanvas();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (prevPageNum != args.pageNum) { //页码改变
|
|
|
|
|
if (prevPageSize == -1) { //刷新按钮,重置为第1页
|
|
|
|
|
self.dataSrc.setPagenum(0);
|
|
|
|
|
self.setPagingOptions({
|
|
|
|
|
pageNum: 0
|
|
|
|
|
}, true);
|
|
|
|
|
} else {
|
|
|
|
|
self.dataSrc.setPagenum(args.pageNum);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (prevPageSize != args.pageSize) { //每页显示行数发生改变
|
|
|
|
|
self.dataSrc.setPagenum(0);
|
|
|
|
|
self.dataSrc.setPageSize(args.pageSize);
|
|
|
|
|
self.setPagingOptions({
|
|
|
|
|
pageNum: 0
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self.dataSrc.search(function() {
|
|
|
|
|
self.vmodel.$grid.resizeCanvas();
|
|
|
|
|
});*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GridAdapter.prototype.setOptions = function (opts) {
|
|
|
|
|
this.vmodel.$grid.getEditorLock().cancelCurrentEdit();
|
|
|
|
|
this.vmodel.$grid.setOptions(opts);
|
|
|
|
|
};
|
|
|
|
|
/**
|
|
|
|
|
* 重绘行高
|
|
|
|
|
*/
|
|
|
|
|
GridAdapter.prototype.resizeRowHeight = function () {
|
|
|
|
|
this.vmodel.$resizeRowHeight();
|
|
|
|
|
};
|
|
|
|
|
GridAdapter.prototype.resizeGrid = function () {
|
|
|
|
|
this.vmodel.$resizeGrid && this.vmodel.$resizeGrid();
|
|
|
|
|
};
|
|
|
|
|
/**
|
|
|
|
|
* 下移一行
|
|
|
|
|
* @return {Function} [description]
|
|
|
|
|
*/
|
|
|
|
|
GridAdapter.prototype.next = function () {
|
|
|
|
|
this.vmodel.$grid.navigateDown();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 上移一行
|
|
|
|
|
* @return {[type]} [description]
|
|
|
|
|
*/
|
|
|
|
|
GridAdapter.prototype.prev = function () {
|
|
|
|
|
this.vmodel.$grid.navigateUp();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据显示行地址获取行数据
|
|
|
|
|
* @param {[type]} index [description]
|
|
|
|
|
* @return {[type]} [description]
|
|
|
|
|
*/
|
|
|
|
|
GridAdapter.prototype.getData = function (index) {
|
|
|
|
|
if (!this.vmodel.$dataView) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return this.vmodel.$dataView.getItem(index);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改网格整体数据
|
|
|
|
|
* @param {[type]} rows [description]
|
|
|
|
|
*/
|
|
|
|
|
GridAdapter.prototype.setData = function (rows) {
|
|
|
|
|
if (!this.vmodel.$dataView) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var grid = this.vmodel.$grid
|
|
|
|
|
if (grid) {
|
|
|
|
|
grid.invalidateAllRows();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.vmodel.$dataView.setItems(rows, '$id');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
GridAdapter.prototype.getItems = function () {
|
|
|
|
|
if (!this.vmodel.$dataView) {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
return this.vmodel.$dataView.getItems();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
GridAdapter.prototype.selectAll = function () {
|
|
|
|
|
this.setSelectedRows(_.range(this.vmodel.$dataView.getItems().length))
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
GridAdapter.prototype.resetSort = function () {
|
|
|
|
|
if (this.vmodel && this.vmodel.$grid) {
|
|
|
|
|
this.vmodel.$grid.setSortColumn(null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GridAdapter.prototype.setEditable = function (isOk) {
|
|
|
|
|
if (!this.vmodel || !this.vmodel.$grid)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var args = {};
|
|
|
|
|
args.editable = isOk;
|
|
|
|
|
args.enableAddRow = isOk && this.dataSrc.allowInsert;
|
|
|
|
|
|
|
|
|
|
this.setOptions(args);
|
|
|
|
|
|
|
|
|
|
this.vmodel.$resetSelectorScrollSize();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
GridAdapter.prototype.updateSelection = function () {
|
|
|
|
|
if (!this.vmodel.$grid) return;
|
|
|
|
|
|
|
|
|
|
var items = this.getItems()
|
|
|
|
|
var rows = []
|
|
|
|
|
for (var i = 0; i < items.length; i++) {
|
|
|
|
|
if (items[i].$is_sel) {
|
|
|
|
|
rows.push(i)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.vmodel.$grid.setSelectedRows(rows)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GridAdapter.prototype.setSelectedRows = function (rows) {
|
|
|
|
|
if (!this.vmodel.$grid) return;
|
|
|
|
|
this.vmodel.$grid.setSelectedRows(rows)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
GridAdapter.prototype.getSelectedRows = function (rows) {
|
|
|
|
|
if (!this.vmodel.$grid) return [];
|
|
|
|
|
return this.vmodel.$grid.getSelectedRows();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
GridAdapter.prototype.onAddNewRow = function (e, args) {
|
|
|
|
|
if (!args.item) {
|
|
|
|
|
var grid = args.grid;
|
|
|
|
|
var dataView = grid.getData();
|
|
|
|
|
grid.invalidateRow(dataView.getLength());
|
|
|
|
|
if (this.dataSrc.allowInsert && this.dataSrc.beforeAddFirstRow()) {
|
|
|
|
|
var dsMaster = this.dataSrc.getMaster();
|
|
|
|
|
if (!dsMaster) {
|
|
|
|
|
this.dataSrc.addRow()
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dsMaster.currentRow) {
|
|
|
|
|
this.dataSrc.addRow()
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
grid.resetActiveCell();
|
|
|
|
|
grid.render();
|
|
|
|
|
}, 100);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
GridAdapter.prototype.onRowsChanged = function (e, args) {
|
|
|
|
|
var grid = args.grid;
|
|
|
|
|
grid.invalidateAllRows();
|
|
|
|
|
grid.render();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
GridAdapter.prototype.render = function () {
|
|
|
|
|
if (!this.vmodel.$grid) return;
|
|
|
|
|
var grid = this.vmodel.$grid
|
|
|
|
|
grid.invalidateAllRows();
|
|
|
|
|
grid.render();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GridAdapter.prototype.onRowCountChanged = function (e, args) {
|
|
|
|
|
var grid = args.grid;
|
|
|
|
|
grid.updateRowCount();
|
|
|
|
|
grid.render();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
GridAdapter.prototype.onBeforeEditCell = function (e, args) {
|
|
|
|
|
var grid = args.grid;
|
|
|
|
|
if (this.dataSrc && args.cell !== null && args.row != null) {
|
|
|
|
|
var dr = args.item,
|
|
|
|
|
dc = grid.getColumns()[args.cell].dataColumn;
|
|
|
|
|
|
|
|
|
|
if (!dr || !dr.isDataRow) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!dc) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//主键字段在行编辑时,不允许编辑
|
|
|
|
|
var allowEdit = !this.dataSrc.getFieldReadOnly(dr, dc);
|
|
|
|
|
|
|
|
|
|
if (!allowEdit) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function checkEditLimitRequire(ds) {
|
|
|
|
|
var curRow = ds.currentRow,
|
|
|
|
|
pass = true;
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < ds.columns.length; i++) {
|
|
|
|
|
var item = ds.columns[i];
|
|
|
|
|
if ((item.fieldName !== "DepId") && (item.fieldName !== "DepCode")) { //2020-06-03临时加上,主要是明细表增加行时老报主表部门不能为空错误
|
|
|
|
|
if (item.isEditLimit && !item.isEmptyField && !curRow[item.fieldName] && curRow[item.fieldName] !== 0) {
|
|
|
|
|
var msg = Store.format(Store.MSG.GRID_EDITLIMIT_FORBIDDEN, item.dispName);
|
|
|
|
|
Store.messager.warn(msg);
|
|
|
|
|
pass = false;
|
|
|
|
|
return pass;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pass;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GridAdapter.prototype.onBeforeActiveCellChanged = function (e, args) {
|
|
|
|
|
var grid = args.grid;
|
|
|
|
|
if (!grid.getOptions().editable) { //grid不可编辑时,不进行行切换校验
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var cell = grid.getActiveCell() || {};
|
|
|
|
|
var newCell = args.newCell
|
|
|
|
|
if (!newCell) return false
|
|
|
|
|
|
|
|
|
|
if (newCell.row != undefined && newCell.cell != undefined && newCell.row !== cell.row) { //行切换校验
|
|
|
|
|
var dataRow = grid.getDataItem(cell.row);
|
|
|
|
|
var onerror = function (msg) {
|
|
|
|
|
//grid.goBackToCell(activeRow, activeCell, true);
|
|
|
|
|
Store.messager.err(msg);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (dataRow && !this.dataSrc.validateDataRow(dataRow, onerror)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
GridAdapter.prototype.onActiveCellChanged = function (e, args) {
|
|
|
|
|
if (!this.dataSrc) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var grid = args.grid;
|
|
|
|
|
var dataSrc = this.dataSrc;
|
|
|
|
|
var cell = grid.getActiveCell();
|
|
|
|
|
if (cell) {
|
|
|
|
|
var dataRow = grid.getDataItem(cell.row);
|
|
|
|
|
|
|
|
|
|
//如果dataRow为有效行,且与数据源当前行不一致则更新当前行
|
|
|
|
|
if (dataRow && dataRow !== dataSrc.currentRow) {
|
|
|
|
|
var oldRow = dataSrc.currentRow;
|
|
|
|
|
dataSrc.setCurrentRow(dataRow);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//界面操作不会导致空行
|
|
|
|
|
//dataSrc.setCurrentRow(null);
|
|
|
|
|
var s = 1;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function setRowIsSelected(grid, rowIndexs, isSelected) {
|
|
|
|
|
let selectedRows = []
|
|
|
|
|
for (var i = 0; i < rowIndexs.length; i++) {
|
|
|
|
|
var idx = rowIndexs[i];
|
|
|
|
|
var row = grid.getDataItem(idx);
|
|
|
|
|
selectedRows.push(row)
|
|
|
|
|
if (row) {
|
|
|
|
|
row.$is_sel = isSelected;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return selectedRows
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GridAdapter.prototype.onSelectedRowsChanged = function (e, args) {
|
|
|
|
|
var grid = args.grid;
|
|
|
|
|
setRowIsSelected(grid, args.previousSelectedRows, false)
|
|
|
|
|
args.selectedRows = setRowIsSelected(grid, args.rows, true)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
GridAdapter.prototype.setFilter = function (filter) {
|
|
|
|
|
var dataView = this.vmodel.$dataView;
|
|
|
|
|
if (dataView) {
|
|
|
|
|
dataView.setFilter(filter);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* [setSelectboxDisable 设置grid第一列的checkbox是否可以点击]
|
|
|
|
|
* @param {[type]} flag [flag为true时设置checkbox为disable,flag为false时设置checkbox为enable]
|
|
|
|
|
*/
|
|
|
|
|
GridAdapter.prototype.setSelectboxDisable = function (flag) {
|
|
|
|
|
var headerId = this.vmodel.$grid.getColumns()[0].id;
|
|
|
|
|
//判断第一列是不是checkboxselector
|
|
|
|
|
if (headerId != "_checkbox_selector") return;
|
|
|
|
|
var headerNode = "<input type='checkbox'" + (flag ? " disabled=true>" : ">");
|
|
|
|
|
if (flag) {
|
|
|
|
|
this.vmodel.$grid.updateColumnHeader(headerId, headerNode);
|
|
|
|
|
}
|
|
|
|
|
for (var i = 0; i < this.vmodel.$columns.length; i++) {
|
|
|
|
|
if (this.vmodel.$columns[i].id === "_checkbox_selector") {
|
|
|
|
|
this.vmodel.$columns[i].uncheckable = flag;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.vmodel.$grid.invalidateAllRows();
|
|
|
|
|
this.vmodel.$grid.render();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GridAdapter.prototype.setColumnEditable = function (field, flag) {
|
|
|
|
|
var columns = this.vmodel.$columns;
|
|
|
|
|
for (var i = 0; i < columns.length; i++) {
|
|
|
|
|
if (columns[i].field == field) {
|
|
|
|
|
columns[i].isReadonly = !flag;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GridAdapter.prototype.setPagingOptions = function (options, force) {
|
|
|
|
|
if (!this.vmodel.$dataView) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.vmodel.$dataView.setPagingOptions(options, force);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GridAdapter.prototype.commitEditor = function () {
|
|
|
|
|
return this.vmodel.$grid.getEditorLock().commitCurrentEdit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GridAdapter.prototype.addContextMenu = function (fn) {
|
|
|
|
|
this._contextMenu = fn;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
GridAdapter.prototype.removeContextMenu = function () {
|
|
|
|
|
delete this._contextMenu;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
GridAdapter.prototype.onRClick = function (e, args) {
|
|
|
|
|
if (this._contextMenu) {
|
|
|
|
|
|
|
|
|
|
//只有网格允许编辑时,才可以弹出右键
|
|
|
|
|
// var editable = this.vmodel.$grid.getOptions().editable;
|
|
|
|
|
// if (editable) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
this._contextMenu({
|
|
|
|
|
top: e.pageY,
|
|
|
|
|
left: e.pageX
|
|
|
|
|
}, {
|
|
|
|
|
data: this.dataSrc,
|
|
|
|
|
items: this.dataSrc.onGetContextMenus(this.id) || []
|
|
|
|
|
});
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
GridAdapter.prototype.toggleRowsSelection = function () {
|
|
|
|
|
this.vmodel.$toggleRowsSelection();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
GridAdapter.prototype.afterDataSrcLoadData = function () {
|
|
|
|
|
this.vmodel.$setHeaderColumnData();
|
|
|
|
|
this.vmodel.$resetSelectorScrollSize();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
GridAdapter.prototype.getSchemaData = function (hasData) {
|
|
|
|
|
if (!this.dataSrc) {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var rows = [],
|
|
|
|
|
columns = [],
|
|
|
|
|
vmodel = this.vmodel;
|
|
|
|
|
var $columns = vmodel.$grid.getColumns();
|
|
|
|
|
for (var i = 0; i < $columns.length; i++) {
|
|
|
|
|
var gridCol = $columns[i];
|
|
|
|
|
if (gridCol.dataColumn) {
|
|
|
|
|
columns.push({
|
|
|
|
|
fieldName: gridCol.dataColumn.fieldName,
|
|
|
|
|
dispName: gridCol.dataColumn.dispName,
|
|
|
|
|
paraValue: gridCol.dataColumn.paraValue
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (hasData) {
|
|
|
|
|
for (var j = 0; j < this.dataSrc.rows.length; j++) {
|
|
|
|
|
var dr = this.dataSrc.rows[j];
|
|
|
|
|
var row = {};
|
|
|
|
|
for (var k = 0; k < columns.length; k++) {
|
|
|
|
|
row[columns[k].fieldName] = dr.getColumnText(columns[k].fieldName);
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
rows.push(row);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var searchParams = this.dataSrc.getSchemaData();
|
|
|
|
|
return {
|
|
|
|
|
uiObjCode: this.dataSrc.uiObjCode,
|
|
|
|
|
funcCode: this.dataSrc.funcCode,
|
|
|
|
|
queryParams: searchParams.queryParams,
|
|
|
|
|
columnParams: searchParams.columnParams,
|
|
|
|
|
rows: rows,
|
|
|
|
|
columns: columns
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
GridAdapter.prototype.getNode = function (row, column) {
|
|
|
|
|
var self = this;
|
|
|
|
|
for (var i = 0; i < self.vmodel.$grid.getOptions().pageSize; i++) {
|
|
|
|
|
if (self.vmodel.$grid.getDataItem(i).$id === row.$id) {
|
|
|
|
|
var rownum = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return self.vmodel.$grid.getCellNode(rownum, column);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
GridAdapter.prototype.destroy = function() {
|
|
|
|
|
if (this.vmodel.$grid) {
|
|
|
|
|
this.vmodel.$grid.destroy()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.dataSrc) {
|
|
|
|
|
this.dataSrc.unmount(this)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return GridAdapter;
|
|
|
|
|
|
|
|
|
|
})
|