rb-data-table
Version:
Angular Smart Table
49 lines • 1.67 kB
JavaScript
import { Cell } from './cell';
var Row = /** @class */ (function () {
function Row(index, data, _dataSet) {
this.index = index;
this.data = data;
this._dataSet = _dataSet;
this.isSelected = false;
this.isInEditing = false;
this.cells = [];
this.process();
}
Row.prototype.getCell = function (column) {
return this.cells.find(function (el) { return el.getColumn() === column; });
};
Row.prototype.getCells = function () {
return this.cells;
};
Row.prototype.getData = function () {
return this.data;
};
Row.prototype.getIsSelected = function () {
return this.isSelected;
};
Row.prototype.getNewData = function () {
var values = Object.assign({}, this.data);
this.getCells().forEach(function (cell) { return values[cell.getColumn().id] = cell.newValue; });
return values;
};
Row.prototype.setData = function (data) {
this.data = data;
this.process();
};
Row.prototype.process = function () {
var _this = this;
this.cells = [];
this._dataSet.getColumns().forEach(function (column) {
var cell = _this.createCell(column);
_this.cells.push(cell);
});
};
Row.prototype.createCell = function (column) {
var defValue = column.settings.defaultValue ? column.settings.defaultValue : '';
var value = typeof this.data[column.id] === 'undefined' ? defValue : this.data[column.id];
return new Cell(value, this, column, this._dataSet);
};
return Row;
}());
export { Row };
//# sourceMappingURL=row.js.map