3

標準の「PulltoRefresh」プラグインでは、リストストアが更新されます。ただし、2つのリストがあり、詳細リスト用に別のストアを更新する必要があります。更新イベントをオーバーライドして他のストアをリロードするにはどうすればよいですか?単純なリスナーを追加しようとしましたが、起動しません。

[アップデート]

私はSenchaサイトからこのスニペットを機能させました:

プラグイン:[
          {{
             xclass:'Ext.plugin.PullRefresh'、
              pullRefreshText:'プルダウンして新しいイベントを増やしてください!'、
              refreshFn:function(plugin){
                  console.log( "私は引っ張られています");
              }
           }
          ]

元のコード:

Ext.define('SenchaFiddle.view.ListView'、{
    拡張:'Ext.dataview.List'、
    xtype:'メインリスト'、

    構成:{
        プラグイン:[
            「プルリフレッシュ」、
            {{
                pullRefreshText:'やる!'、
                タイプ:'listpaging'、
                //「もっと読み込む」メッセージを提供しない
                autoPaging:false、

                refreshFn:function(){             
                  console.log( "ブーム");
                }、

                リスナー:{
                    'updatedata':function(plugin、list){
                        console.log( "データの取得");
                    }
                }

            }
        ]、
        レイアウト:'フィット'、
        幅:300、
        itemTpl:'{テキスト}'

    }
});
4

3 に答える 3

6

Sencha Touch 2.2では、refreshFnExt.util.PullRefreshから設定が削除されました。Ext.util.PullRefresh内の関数を次のようにrefreshFnオーバーライドすることで、新しいバージョンのSenchaTouchでカスタムを正常に実装しました...fetchLatest

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
    }
});
于 2013-06-03T16:37:07.133 に答える
2

sencha-touch-all-debugのExt.plugin.PullRefresh定義を見ると、次の構成が表示されます。

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

設定を通じて必要なことを達成できるのは良い考えかもしれませんrefreshFn

于 2012-05-19T02:52:26.737 に答える
1

refreshFnバックが必要な人のために、のPullRefreshFn拡張機能がありPullRefreshます。

リストやデータビューではなく、パネルによってトリガーされるようにPullRefreshが必要でした。また、ユーザーがPullRefreshをトリガーしたときに、データを手動でロードしてデータビューに設定する必要がありました。

このためにrefreshFn、Sencha 2.2より前に存在していたconfig関数が必要だったので、これが私の実装です。


PullRefreshFn(変更済み)

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's 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);
        }
    }

});

私のコントローラー

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's done setting data, we trigger the snapBack.
                me.populateMylist(function () {
                    me.getMyPanel().getPlugins()[0].snapBack(true);
                });
            }
        }]);
    }

});
于 2014-10-03T05:44:08.377 に答える