简体   繁体   English

ExtjS4中的分页工具栏问题

[英]Paging toolbar problem in ExtjS4

i am new to ExtJS4.I am using paging toolbar in our project.I am clearing the grid using 我是ExtJS4的新手,我在我们的项目中使用分页工具栏。

grid.getStore().removeAll()

Now problem is with paging toolbar.If we click on the buttons then it is retrieving the store.My doubt is how to clear store in paging toolbar? 现在问题出在分页工具栏上,如果我们单击按钮,那么它正在检索商店。我的疑问是如何清除分页工具栏上的商店?

Please help me. 请帮我。

Thanking you, 感谢您,
Kushal 库沙尔

I just spent a few hours researching this thing and wanted to share in case someone is still looking for it. 我只是花了几个小时研究这个东西,并想分享一下,以防有人还在寻找它。 It looks like Ext.toolbar.Paging does not listen to the clear event of the store which fires on the removeAll() method. 看起来Ext.toolbar.Paging不会侦听在removeAll()方法上触发的商店的clear事件。 My solution was to sub class it and override getStoreListeners to bind onLoad internal function to the clear event. 我的解决方案是对其进行子类化并重写getStoreListeners,以将onLoad内部函数绑定到clear事件。 I am using ExtJS 4.1 by the way. 我正在使用ExtJS 4.1。

Ext.define('MyApp.ClearablePagingToolbar', {
    extend: 'Ext.toolbar.Paging',
    alias: 'widget.clearablepagingtoolbar',
    getStoreListeners: function () {
        var listeners = this.callParent();

        Ext.apply(listeners, {
            clear: this.onLoad
        });

        return listeners;
    }
});

You use it by referencing clearablepagingtoolbar in your grid like this: 您可以通过在网格中引用clearablepagingtoolbar来使用它,如下所示:

dockedItems: [{
    xtype: 'clearablepagingtoolbar',
    dock: 'bottom',
    displayInfo: true,
    store: this.getSearchResultStore()
}]

First of all, do you have the same store configured for both the grid and the toolbar? 首先,您是否为网格和工具栏配置了相同的存储库? If yes, you should try to clear the store itself, and not by using grid.getStore() (eg myStore.removeAll() ) 如果是,则应尝试清除商店本身,而不要使用grid.getStore()(例如,myStore.removeAll())

If you grid and paging toolbar uses same store, your paging toolbar will work correct. 如果网格和分页工具栏使用相同的存储,则分页工具栏将正常工作。 If you use separate stores (It is bad coding style), you need to call this paging panel's store's sync method, to syncronize data. 如果使用单独的存储(这是不好的编码风格),则需要调用此分页面板的​​存储的sync方法来同步数据。

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

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