How to add custom update when pull upgrade?

The standard Pull to Refresh plugin updates the list. However, I have two lists, and I need to update another store for my detailed list. How can I override the update event and reload another store? I tried to add a simple listener, but he did not shoot.

[Update]

I got this snippet from Sencha site to work:

plugins: [
          {
             xclass: 'Ext.plugin.PullRefresh',
              pullRefreshText: 'Pull down for more new Events!',
              refreshFn: function (plugin) {
                  console.log ("I'm pulled");
              }
           }
          ]

Source:

Ext.define ('SenchaFiddle.view.ListView', {
    extend: 'Ext.dataview.List',
    xtype: 'main-list',

    config: {
        plugins: [
            'pullrefresh',
            {
                pullRefreshText: 'Do it!',
                type: 'listpaging',
                // Don't offer "Load More" msg
                autoPaging: false,

                refreshFn: function () {             
                  console.log ("Boom");
                },

                listeners: {
                    'updatedata': function (plugin, list) {
                        console.log ("Getting the data");
                    }
                }

            }
        ],
        layout: 'fit',
        width: 300,
        itemTpl: '{text}'

    }
});
+3
3

Ext.plugin.PullRefresh sencha-touch-all-debug, :

    /*
     * @cfg {Function} refreshFn The function that will be called to refresh the list.
     * If this is not defined, the store load function will be called.
     * The refresh function gets called with a reference to this plugin instance.
     * @accessor
     */
    refreshFn: null,

, , , refreshFn config.

+2

Sencha Touch 2.2 refreshFn Ext.util.PullRefresh. refreshFn Sencha Touch, fetchLatest Ext.util.PullRefresh, ...

Ext.define('MyApp.overrides.PullRefreshOverride', {
    override: 'Ext.plugin.PullRefresh',

    fetchLatest: function() {
        var list = this.getList();

        switch(list.getItemId()) {
            case "list1": 
                this.updateStore1();
                break;

            case "list2": 
                this.updateStore2();
                break;
        }

        this.callParent(arguments);
    },

    //My own custom function to add to the plugin
    updateStore1: function() {
        //Code to update store 1
    },

    //My own custom function to add to the plugin
    updateStore2: function {
        //Code to update store 2
    }
});
+6

, refreshFn back, PullRefreshFn PullRefresh.

PullRefresh , List Dataview, Dataview PullRefresh.

refreshFn, Sencha 2.2, .


PullRefreshFn (changed)

Ext.define('Ext.plugin.PullRefreshFn', {
    extend: 'Ext.plugin.PullRefresh',
    alias: 'plugin.pullrefreshfn',
    requires: ['Ext.DateExtras'],

    config: {
        /**
         * @cfg {Function} refreshFn The function that will be called to refresh the list.
         * If this is not defined, the store load function will be called.
         */
        refreshFn: null
    },

    fetchLatest: function() {
        if (this.getRefreshFn()) {
            this.getRefreshFn().call();
        } else {
            var store = this.getList().getStore(),
                proxy = store.getProxy(),
                operation;

            operation = Ext.create('Ext.data.Operation', {
                page: 1,
                start: 0,
                model: store.getModel(),
                limit: store.getPageSize(),
                action: 'read',
                sorters: store.getSorters(),
                filters: store.getRemoteFilter() ? store.getFilters() : []
            });

            proxy.read(operation, this.onLatestFetched, this);
        }
    }

});

My controller

Ext.define('myApp.controller.MyController', {
    extend: 'Ext.app.Controller',
    requires: ['Ext.plugin.PullRefreshFn'],

    ...

    // More code

    ...

    // Binds the Pull Refresh to myPanel view item.
    // myPanel is a panel. Not list nor dataview.
    setPullRefresh: function () {
        var me = this;

        // We get reference to myPanel and
        // we set PullRefreshFn
        this.getMyPanel().setPlugins([{
            xclass: 'Ext.plugin.PullRefreshFn',
            docked: 'top',

            // We set autoSnapBack to false,
            // as we are going to trigger this manually
            autoSnapBack: false,

            // refreshFn will be called upon user releasing for refresh.
            refreshFn: function() {

                // This is a custom function that sets data to our dataview list.
                // When it done setting data, we trigger the snapBack.
                me.populateMylist(function () {
                    me.getMyPanel().getPlugins()[0].snapBack(true);
                });
            }
        }]);
    }

});
+1
source

All Articles