filterRows(evalFn?: Function) { const columns = this.columnManager.columns; this.createFilterExpression(); if (!this.filterExpression) { this.rows = toArray(this.rowsIterator.clone()); this.columnManager.dataGrid.resize(); return; } const formatFns = {}; formatFns[COLUMN_TYPES.index] = columns[COLUMN_TYPES.index].map(column => column.formatFn); formatFns[COLUMN_TYPES.body] = columns[COLUMN_TYPES.body].map(column => column.formatFn); try { this.rows = toArray(filter( this.rowsIterator.clone(), (row) => evalFn ? evalFn(row, formatFns) : this.evaluateFilterExpression(row, formatFns) )); this.sortedBy && this.sortByColumn(this.sortedBy); this.columnManager.dataGrid.resize(); } catch (e) {} }
createRowsWithGeneratedIndex(data) { this.rowsIterator = new MapIterator<any[], DataGridRow>( iter(data), (values, index) => new DataGridRow(index, values) ); this.rows = toArray(this.rowsIterator.clone()); }
createRowsWithIndex(data) { this.rowsIterator = new MapIterator<any[], DataGridRow>( iter(data), (values) => new DataGridRow(values[0], values.slice(1) )); this.rows = toArray(this.rowsIterator.clone()); }