Skip to content

Commit

Permalink
feat: rest selected page on data change and filter change
Browse files Browse the repository at this point in the history
  • Loading branch information
markuczy committed Jul 30, 2024
1 parent 5ec11fd commit c26161e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export class DataListGridComponent extends DataSortBase implements OnInit, DoChe
return this._data$.getValue()
}
set data(value: RowListGridData[]) {
this.resetPage()
this._originalData = [...value]
this._data$.next([...value])
}
Expand Down Expand Up @@ -376,6 +377,11 @@ export class DataListGridComponent extends DataSortBase implements OnInit, DoChe
this.pageChanged.emit(page)
}

resetPage() {
this.page = 0
this.pageChanged.emit(this.page)
}

fieldIsTruthy(object: any, key: any) {
return !!this.resolveFieldData(object, key)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export class DataTableComponent extends DataSortBase implements OnInit {
return this._rows$.getValue()
}
set rows(value: Row[]) {
this.resetPage()
this._rows$.next(value)
}
_selection$ = new BehaviorSubject<Row[]>([])
Expand Down Expand Up @@ -338,6 +339,7 @@ export class DataTableComponent extends DataSortBase implements OnInit {
this.filters = filters
}
this.filtered.emit(filters)
this.resetPage()
}

getSelectedFilters(columnId: string): string[] | undefined {
Expand Down Expand Up @@ -383,6 +385,11 @@ export class DataTableComponent extends DataSortBase implements OnInit {
this.pageChanged.emit(page)
}

resetPage() {
this.page = 0
this.pageChanged.emit(this.page)
}

fieldIsTruthy(object: any, key: any) {
return !!ObjectUtils.resolveFieldData(object, key)
}
Expand Down

0 comments on commit c26161e

Please sign in to comment.