UNPKG

e-virt-table

Version:

A powerful data table based on canvas. You can use it as data grid、Microsoft Excel or Google sheets. It supports virtual scroll、cell edit etc.

127 lines 3.7 kB
import Cell from './Cell'; export default class Row { constructor(ctx, rowIndex, x = 0, y = 0, width = 0, height = 0, data, rowType = 'body') { Object.defineProperty(this, "ctx", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "x", { enumerable: true, configurable: true, writable: true, value: 0 }); Object.defineProperty(this, "y", { enumerable: true, configurable: true, writable: true, value: 0 }); Object.defineProperty(this, "width", { enumerable: true, configurable: true, writable: true, value: 0 }); Object.defineProperty(this, "height", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "cells", { enumerable: true, configurable: true, writable: true, value: [] }); Object.defineProperty(this, "fixedCells", { enumerable: true, configurable: true, writable: true, value: [] }); Object.defineProperty(this, "noFixedCells", { enumerable: true, configurable: true, writable: true, value: [] }); Object.defineProperty(this, "rowIndex", { enumerable: true, configurable: true, writable: true, value: 0 }); Object.defineProperty(this, "rowKey", { enumerable: true, configurable: true, writable: true, value: '' }); Object.defineProperty(this, "rowType", { enumerable: true, configurable: true, writable: true, value: 'body' }); Object.defineProperty(this, "data", { enumerable: true, configurable: true, writable: true, value: void 0 }); this.ctx = ctx; this.x = x; this.y = y; this.width = width; this.height = height; this.rowIndex = rowIndex; this.rowKey = ctx.database.getRowKeyForRowIndex(rowIndex) || ''; this.rowType = rowType; this.data = data; this.update(); } update() { const { header } = this.ctx; const cells = []; const fixedCells = []; const noFixedCells = []; header.renderLeafCellHeaders.forEach((header) => { const cell = new Cell(this.ctx, this.rowIndex, header.colIndex, header.x, this.y, header.width, this.height, header.column, this.data, this.rowType); if (cell.fixed) { fixedCells.push(cell); } else { noFixedCells.push(cell); } cells.push(cell); }); this.cells = cells; this.fixedCells = fixedCells; this.noFixedCells = noFixedCells; } drawCenter() { this.noFixedCells.forEach((cell) => { cell.draw(); }); } drawFixed() { this.fixedCells.forEach((cell) => { cell.draw(); }); } drawContainer() { this.noFixedCells.forEach((cell) => { cell.drawContainer(); }); } drawFixedContainer() { this.fixedCells.forEach((cell) => { cell.drawContainer(); }); } } //# sourceMappingURL=Row.js.map