简体   繁体   English

使用秋田/状态管理从 Angular 物料表中的详细信息页面导航返回后,维护搜索页面的 state

[英]Maintain state of Search page after navigating back from details page in Angular Material table using Akita/State management

I am looking for any working example where I can save the search filter state,pagination state after a click on the detail page and coming back to using the location.back() function.我正在寻找可以保存搜索过滤器 state,pagination state 的任何工作示例,然后单击详细信息页面并返回使用 location.back() ZC1C425268E68385D1AB5074C17A4。

I am using the Akita store and angular material table in my application to maintain the state.我在我的应用程序中使用秋田商店和 angular 材料表来维护 state。

I was going through one of the AkitaFilter plugins but they are lacking documentation and examples.我正在浏览其中一个 AkitaFilter 插件,但它们缺少文档和示例。 Can anyone have a solution using any NGRX or Akita State management to save the state in the angular material table?任何人都可以使用任何 NGRX 或秋田 State 管理来将 state 保存在 angular 材料表中的解决方案吗?

you can store your current state of table in your localstorage like this in each filter's function you can do您可以像这样在每个过滤器的 function 中将表的当前 state 存储在本地存储中,您可以这样做

localStorage.setItem('state', JSON.stringify(this.store.getState()));

Alternatively you can store your grid/table's filter state in your localstorage , Like you can store currentPage, sortOrdet etc in your localstorage.或者,您可以将grid/table's filter state 存储在localstorage中,就像您可以将currentPage, sortOrdet等存储在 localstorage 中一样。 Because if you want your data to be persistent even after navigation or page refresh so you can store in localstorage because state management stores are also services based architecture in which data can't be persistent.因为如果您希望您的数据即使在导航或页面刷新之后仍然存在,那么您可以存储在state localstorage stores也是基于服务的体系结构,其中数据不能持久存在。

You can do this in a way that inside your pagination button function you can store your current page in your localstorage each time your function will be called.您可以通过在您的pagination按钮 function 中执行此操作,每次调用localstorage时,您都可以将当前页面存储在本地存储中。 And same goes for sorting function. sorting function 也是如此。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 导航回具有相同状态的搜索页面 (JavaScript) - Navigating back to Search Page with same state (JavaScript) 使用“返回”返回页面时如何保持复选框禁用状态? - How to maintain checkbox disabled state when returning to page using Back? 从编辑页面返回到详细信息时,反应状态未呈现 - react state is not rendering on coming back from edit page to details 在使用`pushState`后浏览浏览器历史记录时,如何在我的Vue.js页面中执行状态更改? - How do perform state changes in my Vue.js page when navigating back through browser history after using `pushState`? 导航离开并返回 Angular 后,有没有办法保留组件的 DOM state - Is there a way to preserve DOM state of the component after navigating away and back in Angular 导航回地图页面时恢复谷歌地图状态 - Restoring google map state when navigating back to map page 更新当前页面URL,但保持后退按钮状态 - Update current page URL but maintain the back button state 单击浏览器后退按钮时如何维护页面状态? - How to maintain the page state when browser back button is clicked? 在页面刷新时,保持导航栏状态 - On page refresh, maintain the navbar state 如果用户离开页面,如何维护页面状态? - How to maintain page state if user navigates away from page?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM