简体   繁体   English

在 ExtJS 中的选项卡开关上更新网格面板

[英]Update Grid Panel on Tab Switch in ExtJS

I have two separate tabs (Tab A & Tab B).我有两个单独的选项卡(选项卡 A 和选项卡 B)。 These two tabs share a single store wherein each are in their respective indices.这两个选项卡共享一个存储,每个存储在各自的索引中。 [0] - A , and [1] - B . [0] - A[1] - B

My controller initializes the load upon click on its menu leaf such as:我的控制器在单击其菜单叶时初始化负载,例如:

oMe.control({
  '#role-permission-grid-panel': {

    edit: oMe.save,

    beforerender: oMe.loadData,

  },
  '#roles-applicationtype button': {
    click: oMe.filterByApplication
  }
});

applicationtype button is the filter where tab switching of loaded data happens. applicationtype button是加载数据的选项卡切换发生的过滤器。

When trying to catch the value of the current filter, the controller successfully shows which one was clicked.当试图捕捉当前过滤器的值时,控制器成功显示点击了哪个。 However, this no longer refreshes the grid panel data.但是,这不再刷新网格面板数据。

SampleGridPanel /view : SampleGridPanel /视图

console.log('Application',oController.sDefaultToggle);

Simply put, I update the data from SampleController , and try to catch it from my SampleGridPanel by calling filterApplication .简单地说,我从SampleController更新数据,并尝试通过调用filterApplication从我的SampleGridPanel捕获它。 My SampleGridPanel only loads the store once due to initComponent .由于initComponent我的SampleGridPanel仅加载一次商店。 I want to pass the updated data (in this case the selected tab) from the controller to the view .我想将更新的数据(在这种情况下是选定的选项卡)从controller传递到view How do I notify my view that this change occurred when it only identifies data on initial load?当我的视图仅识别初始加载数据时,如何通知我的视图发生了此更改?

I'm also a bit confused.我也有点糊涂了。 On my controller, when calling oMe.loadData beforerender , it knows the last tabbed value, but when I call oMe.loadData from a custom filter function, it no longer reloads the entire store.在我的控制器,打电话时oMe.loadData beforerender ,它知道最后一个标签式的值,但是当我打电话oMe.loadData从自定义过滤功能,它不再重新加载整个商店。 It only loads the filtered information based on the filter value.它仅根据过滤器值加载过滤后的信息。

You could listen to the activate and deactivate events of the tabpanel.您可以收听 tabpanel 的activatedeactivate事件。 These are also available in older versions of ExtJS.这些也可以在旧版本的 ExtJS 中使用。

If you are using ExtJS 6, you should really consider using ChainedStore .如果你使用 ExtJS 6,你真的应该考虑使用ChainedStore

  • A Store contains the data. Store 包含数据。
  • The grids aren't bound to the store, but to a ChainedStore each.网格不绑定到商店,而是每个都绑定到一个 ChainedStore。
  • The ChainedStores have their source set to the store, and use different filter to only get the data that should be shown in their respective grid. ChainedStores 将其源设置为商店,并使用不同的过滤器仅获取应显示在其各自网格中的数据。

Please note that as of ExtJS 6.0.1 there were bugs in ExtJS that exhibited when combining ChainedStore with GroupingFeature or CellEditing .请注意,从 ExtJS 6.0.1 开始,当将ChainedStoreGroupingFeatureCellEditing结合使用时,ExtJS 中存在一些错误。 These should be fixed in ExtJS 6.0.2.这些应该在 ExtJS 6.0.2 中修复。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM