aslagle / reactive-table

A reactive table designed for Meteor
https://atmospherejs.com/aslagle/reactive-table
Other
328 stars 137 forks source link

Combine filter and currentPage #377

Open ddresch opened 8 years ago

ddresch commented 8 years ago

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.

aslagle commented 8 years ago

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.

ddresch commented 8 years ago

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.

aslagle commented 8 years ago

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.

ddresch commented 8 years ago

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?

aslagle commented 8 years ago

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.