Search code examples
backbone.jsbackgrid

How does Backgrid know what numbers to generate for pagination?


I'm implementing pagination for my Backgrid powered tables, like so:

footer: Backgrid.Extension.Paginator

And in my Collection:

state: {
   pageSize: 15
}

Now, I haven't actually implemented any handling of pagination server side (which is what I feel might be producing odd results), but it put this HTML in:

enter image description here

Any ideas anyone?


Solution

  • This is sort of a bug and sort of a mismatched expectation.

    The reason it started paging backwards is because your server mode Backbone.PageableCollection didn't have a totalRecords set in state, which is required under server mode according to the documentation.

    In addition, Backgrid.Extension.Paginator has a default sliding window of 10 pages, but apparently version 0.1 made an assumption that the collection won't be empty when you decide to summon up a grid, (it basically assumed you'd follow the recommended best practice here), so this case was never checked. Following the progress of this issue here.