reactive-table icon indicating copy to clipboard operation
reactive-table copied to clipboard

Combine filter and currentPage

Open ddresch opened this issue 9 years ago • 5 comments

I'm using a settings object like this:

{
  fields: []
  filters: []
  currentPage: ReactiveVar
  id: "listname" <- not sure if this still has a meaning, saw an issue about storing filters
}

Nothing special, the problem are the filters which force the list to jump back to page 1, per default.

How is it possible to "remember" the currentPage position without reactive-table overriding to 0?

The Session handling of simple lists without filters is going right, the moment you use filters it behaves like this.

I mean it's a common use case - filter a list then edit an item going back to list.

ddresch avatar Apr 06 '16 00:04 ddresch

I think it's necessary to go back to page 1 when the filter changes - filtering makes the table smaller, and you wouldn't want to end up on a page that was past the rows you were on or even past the end of the table.

You could use the session to store more page number history, instead of only mirroring the current page of the table, if you want to be able to go back farther.

aslagle avatar Apr 06 '16 02:04 aslagle

Thanks a lot for your quick response!!!

Don't you think it makes sense to store the item count internally and check if it changed when setting currentPage again? Like this it's more easy to handle when using the component.

ddresch avatar Apr 06 '16 13:04 ddresch

I'm not sure all applications would want this to work the same way, so I'd rather make it possible to add on externally than have configuration options and more complicated code in the package.

aslagle avatar Apr 07 '16 12:04 aslagle

Hmm ok but to handle this properly outside of the component, we'll need a kind of external API to access e.g. pageCount etc.

To call e.g. this method: https://github.com/aslagle/reactive-table/blob/master/lib/reactive_table.js#L333

A bit like autoform is doing it with an global id per form / table.

ReactiveTable.getPageCount(tableId);

What you think?

ddresch avatar Apr 07 '16 13:04 ddresch

An external API is a great idea but I don't have time to do it. I'd probably prefer something more along the lines of creating a ReactiveTable object you can call methods on and also pass in to the template, rather than relying on global ids.

aslagle avatar Apr 11 '16 01:04 aslagle