Watch for changes in table data in corTable control
Prevents stale data from appearing in the table
This commit is contained in:
parent
288ef0f5b5
commit
c8ee889272
1 changed files with 9 additions and 2 deletions
|
@ -10,7 +10,7 @@ import { CorTableColumn } from './cor-table-col.component';
|
||||||
transclude: true,
|
transclude: true,
|
||||||
})
|
})
|
||||||
export class CorTableComponent implements ng.IComponentController {
|
export class CorTableComponent implements ng.IComponentController {
|
||||||
@Input('=') public tableData: any[];
|
@Input('<') public tableData: any[];
|
||||||
@Input('@') public tableItemTitle: string;
|
@Input('@') public tableItemTitle: string;
|
||||||
@Input('<') public filterFields: string[];
|
@Input('<') public filterFields: string[];
|
||||||
@Input('@') public compact: string;
|
@Input('@') public compact: string;
|
||||||
|
@ -30,6 +30,12 @@ export class CorTableComponent implements ng.IComponentController {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public $onChanges(changes: ng.IOnChangesObject): void {
|
||||||
|
if (changes['tableData'] !== undefined) {
|
||||||
|
this.refreshOrder();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public addColumn(col: CorTableColumn): void {
|
public addColumn(col: CorTableColumn): void {
|
||||||
this.columns.push(col);
|
this.columns.push(col);
|
||||||
|
|
||||||
|
@ -64,7 +70,8 @@ export class CorTableComponent implements ng.IComponentController {
|
||||||
return col.isNumeric();
|
return col.isNumeric();
|
||||||
}).map((col) => (col.datafield));
|
}).map((col) => (col.datafield));
|
||||||
|
|
||||||
var processed = this.tableData.map((item) => {
|
var tableData = this.tableData || [];
|
||||||
|
var processed = tableData.map((item) => {
|
||||||
var keys = Object.keys(item);
|
var keys = Object.keys(item);
|
||||||
var newObj = {};
|
var newObj = {};
|
||||||
for (var i = 0; i < keys.length; ++i) {
|
for (var i = 0; i < keys.length; ++i) {
|
||||||
|
|
Reference in a new issue