Search code examples
backbone.jsbackgrid

Backgrid sort issue server side


I'm somewhat new to backgrid, so maybe I'm missing something obvious, but I can't seem to get sever side sorting working:

My PageableCollection is configured like this:

  state: {
        pageSize: 10,
        order: 1,
        //,
        totalRecords:315586
      },
  queryParams: {
        currentPage:'page',
        pageSize: 'size',
        sortKey: "sort"
      },

The problem is, the sort direction doesn't get "reset" after the results return.

So a request goes out like this:

?page=1&size=10&total_pages=31559&sort=name&order=asc

The results come back sorted the ascending arrow flashes briefly and goes away, clicking a second time:

?page=1&size=10&total_pages=31559&sort=name&order=asc

As you can see, the order hasn't changed.

My return results look something like this:

[{"sort": "name", "total_entries": 315586, "order": "asc"}, [{},...]]

Pagination works fine. I can skip around from page 1 to page 6 or whatever.


Solution

  • Mmm, this might be a bug. When the collection resets all the sort directions would be reset. Can you file a bug with the exact steps to reproduce it?

    This was a defect fixed by: https://github.com/wyuenho/backgrid-paginator/issues/15