purecloudlabs/fixtable-ember

Maintain component state on route transition

Opened this issue · 1 comments

Is there a recommended way to maintain the state of filters/sorts/page on route transition?

I could potentially store this data in a service but I still need to set the actual text in the search boxes for each column. Is there any way to achieve this without dom manipulation?

If there's an option to set default values for filters, sort order, and page number when the component is initialized, that would be great.

There is currently not a clean way to do this. You can make use of the externalFilters feature that was very recently added, but you would have to build the UI around filters yourself ( not using the column filters included in the addon ). Or, you can define a custom filter component and use an Ember service to keep track of its state.

Having said that, here is the dirty way to update both of those:
{{fixtable-grid ... currentPage=myCurrentPage filters=myFilters}}
and in your controller:
... myCurrentPage: 3, myFilters: { idOfField: 'textToShowInFieldOrSelectValue } ...

NOTE that this will NOT trigger any data reload, but will dirty bind / set these variables for you. In my limited testing of this hack, onReloadContent doesn't even pass down your filters ( but it does pass the custom set page down ).