UNPKG

ng2-stable-nxtc

Version:

Angular Smart Table neXtCode Version

46 lines 1.38 kB
import { Cell } from './cell'; export class Row { constructor(index, data, _dataSet) { this.index = index; this.data = data; this._dataSet = _dataSet; this.isSelected = false; this.isInEditing = false; this.cells = []; this.process(); } getCell(column) { return this.cells.find(el => el.getColumn() === column); } getCells() { return this.cells; } getData() { return this.data; } getIsSelected() { return this.isSelected; } getNewData() { const values = Object.assign({}, this.data); this.getCells().forEach((cell) => values[cell.getColumn().id] = cell.newValue); return values; } setData(data) { this.data = data; this.process(); } process() { this.cells = []; this._dataSet.getColumns().forEach((column) => { const cell = this.createCell(column); this.cells.push(cell); }); } createCell(column) { const defValue = column.settings.defaultValue ? column.settings.defaultValue : ''; const value = typeof this.data[column.id] === 'undefined' ? defValue : this.data[column.id]; return new Cell(value, this, column, this._dataSet); } } //# sourceMappingURL=row.js.map