Skip to content

Commit

Permalink
Merge pull request #980 from wizarrc/patch-8
Browse files Browse the repository at this point in the history
Adds bounds to offset Fixes #978
  • Loading branch information
amcdnl authored Sep 12, 2017
2 parents 80f13e0 + 78a6c46 commit e5dc5a0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/datatable.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,12 @@ export class DatatableComponent implements OnInit, DoCheck, AfterViewInit {
* The current offset ( page - 1 ) shown.
* Default value: `0`
*/
@Input() offset: number = 0;
@Input() set offset(val: number) {
this._offset = val;
}
get offset(): number {
return Math.max(Math.min(this._offset, Math.ceil(this.rowCount / this.pageSize) - 1), 0);
}

/**
* Show the linear loading bar.
Expand Down Expand Up @@ -595,6 +600,7 @@ export class DatatableComponent implements OnInit, DoCheck, AfterViewInit {

_limit: number | undefined;
_count: number = 0;
_offset: number = 0;
_rows: any[];
_groupRowsBy: string;
_internalRows: any[];
Expand Down

0 comments on commit e5dc5a0

Please sign in to comment.