Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reseting page offset on input data change #516

Merged
merged 3 commits into from
Feb 20, 2017
Merged

reseting page offset on input data change #516

merged 3 commits into from
Feb 20, 2017

Conversation

ritikrishu
Copy link
Contributor

What kind of change does this PR introduce? (check one with "x")

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behaviour? (You can also link to an open issue here)
Suppose my current offset is 10, limit is 10 and I have 100 rows to display. Now when I filter data based on some search or something I am left with 10 or 15 rows. The total count in footer is updated as expected but all rows are disappeared as the offset is not being reset.
issue: #515

What is the new behaviour?
Reset offset to zero(page 1) whenever rows input is changed.

Does this PR introduce a breaking change? (check one with "x")

  • Yes
  • No

If this PR contains a breaking change, please describe the impact and migration path for existing applications: ...

Other information:
One other approach can be checking if current offset have data to display and then reset offset accordingly.
Basically something like:

recalculatePages(): void {
    this.pageSize = this.calcPageSize();
    this.rowCount = this.calcRowCount();
    // on input data set change switch to the starting page offset, if total rows are lesser than current offset * limit
    if(this.rowCount / this.pageSize < this.offset) { 
      this.offset = 0;
    }
  }

but I think the current PR implementation provides more consistent behaviour.

@amcdnl amcdnl merged commit 995ecf6 into swimlane:master Feb 20, 2017
deeg added a commit to deeg/angular2-data-table that referenced this pull request Feb 21, 2017
Do not set offset to 0 when rows are changed so that you can show data loaded from the server for the second page.
Reverts swimlane#516
@deeg deeg mentioned this pull request Feb 21, 2017
9 tasks
@ritikrishu ritikrishu deleted the patch1 branch February 22, 2017 10:50
rsparrow pushed a commit to rsparrow/ngx-datatable that referenced this pull request Jun 2, 2017
reseting page offset on input data change
rsparrow pushed a commit to rsparrow/ngx-datatable that referenced this pull request Jun 2, 2017
Do not set offset to 0 when rows are changed so that you can show data loaded from the server for the second page.
Reverts swimlane#516
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants