Merge pull request #2566 from alecmerdler/cor-table-improvement

Allow All Item Properties in CorTableComponent Columns
This commit is contained in:
Alec Merdler 2017-04-21 13:31:16 -07:00 committed by GitHub
commit 81d3ac71df

View file

@ -54,8 +54,7 @@ export class CorTableComponent implements OnChanges {
} }
private tablePredicateClass(col: CorTableColumn, options: any) { private tablePredicateClass(col: CorTableColumn, options: any) {
return this.TableService.tablePredicateClass(col.datafield, this.options.predicate, return this.TableService.tablePredicateClass(col.datafield, this.options.predicate, this.options.reverse);
this.options.reverse);
} }
private refreshOrder(): void { private refreshOrder(): void {
@ -64,28 +63,24 @@ export class CorTableComponent implements OnChanges {
columnMap[col.datafield] = col; columnMap[col.datafield] = col;
}); });
var filterCols = this.columns.filter(function(col) { const filterCols = this.columns.filter(col => !!col.sortfield)
return !!col.sortfield; .map(col => col.datafield);
}).map((col) => (col.datafield));
var numericCols = this.columns.filter(function(col) { const numericCols = this.columns.filter(col => col.isNumeric())
return col.isNumeric(); .map(col => col.datafield);
}).map((col) => (col.datafield));
var tableData = this.tableData || []; const tableData = this.tableData || [];
var processed = tableData.map((item) => { const processed = tableData.map((item) => {
var keys = Object.keys(item); var newObj = Object.assign({}, item);
var newObj = {}; Object.keys(item).forEach((key) => {
for (var i = 0; i < keys.length; ++i) {
var key = keys[i];
if (columnMap[key]) { if (columnMap[key]) {
newObj[key] = columnMap[key].processColumnForOrdered(this.TableService, item[key]); newObj[key] = columnMap[key].processColumnForOrdered(this.TableService, item[key]);
} }
} });
return newObj; return newObj;
}); });
this.orderedData = this.TableService.buildOrderedItems(processed, this.options, this.orderedData = this.TableService.buildOrderedItems(processed, this.options, filterCols, numericCols);
filterCols, numericCols);
} }
} }