Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions projects/simplified-ui/src/lib/models/DataTableModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,18 @@ export class DataTable<T> {
* @param index Index at which the column should be added.
*/
addColumn(column: IDataTableColumn, index?: number): void {
if (index) {
this.columns.splice(index, 0, column);
// updates the existing column when key is same
if (this.columns.some(i => i.key == column.key)) {
var prevColumnIndex = this.columns.findIndex(i => i.key == column.key);
this.columns[prevColumnIndex] = column;
} else {
this.columns.push(column);
if (index) {
this.columns.splice(index, 0, column);
} else {
this.columns.push(column);
}
}

this.columnAddedSubject.next(column);
this.columnsUpdatedSubject.next(this.columns);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,12 @@ export class SaDataTableComponent<T> implements OnInit, AfterViewInit, OnDestroy

ngOnInit() {
this.actionsTemplate = this.dataTable.actionsTemplate;

this.dataTable.onColumnRemoved().subscribe(res => {
this.filterArray = this.filterArray.filter(x => x.key != res.filter.key)
});

this.dataTable.onColumnUpdated().subscribe((columns) => {
this.filterArray = [];
columns.forEach((z) => {
if (z.filter != null) this.filterArray.push(z.filter);
});
Expand Down