1

Grid Filter リストを動的に設定しようとすると、奇妙な問題が発生します。

私のコードスニペットで説明しましょう

フィルターリストが次のように定義されている列があります

         { 
            text        : 'Client',
            dataIndex   : 'topAccount', 
            itemId  : 'exTopAccount',

            filter: {
                       type: 'list',
                       options:[]

                    }
        }

「viewready」のストアからリストを初期化します

 viewready: function(cmp,eOpts){

                    cmp.getHeaderCt().child('#exTopAccount').initialConfig.filter.options = clientsStore.collect('topAccount');
            }

===>うまくいく

ここで、ユーザーが次のページに移動したときに、レコードに基づいて新しいクライアント ストアを構築する必要があります。したがって、ページングの「変更」イベントでストアを構築します

listeners: {
               'change' :function( toolbar, pageData, eOpts ) { 
                   var store = Ext.StoreManager.get('ExceptionRecords');
                   clientsStore.removeAll(true);
                    store.each(function(record){                           
                         if(clientsStore.findRecord('topAccount',record.data.topAccount.trim()) == null ) {                                 
                            clientsStore.add({topAccount: record.data.topAccount.trim()})
                         }
                    })      
                    Ext.getCmp('exceptionGridContainer').view.refresh;
                    Ext.getCmp('exceptionGridContainer').view.getHeaderCt().doLayout;


                    console.log(clientsStore);
                    Ext.getCmp('exceptionGridContainer').view.getHeaderCt().child('#exTopAccount').initialConfig.filter.options = clientsStore.collect('topAccount');



                } 
           } 

clientStore に新しいデータが表示されるようになりました。ただし、グリッド フィルター リストは更新されません。まだ古いデータを表示しています。リフレッシュ、レイアウトなどを試しましたが、何も役に立ちません

どんな助けでも大歓迎です

ありがとうタラハン

4

2 に答える 2

2

プロパティの値を変更するだけでは、コンポーネントのレンダリングまたは計算された状態には影響しません。メニューは、リストが最初に初期化されるときに作成されます。初めてそれを行うと、それは初期化の前であるため機能しますが、2回目は遅すぎます。

インスタンス化された への参照を取得できる場合はListFilter、次の方法でメニューを強制的に再作成できると思います。

listFilter.menu = listFilter.createMenu({
    options: [ ... ] // new options
    // rest of the filter config
});

したがって、 target への参照があると仮定すると、次のような呼び出しで「topAccount」gridの列のオプションを変更できます。dataIndex

var listFilter = grid
    .findFeature('filters') // access filters feature of the grid
    .get('topAccount'); // access the filter for column
listFilter.menu = listFilter.createMenu({
    options: [ ... ] // new options
    // rest of the filter config
});

- - 編集 - -

OK、完全な例。テスト済み、動作中

Ext.widget('grid', {
    renderTo: Ext.getBody()

    ,height: 400

    ,features: [{
        ftype: 'filters'
        ,local: true
    }]

    ,columns: [{
        dataIndex: 'a'
        ,text: 'Column A'
        ,filter: {
            type: 'list'
            ,options: ['Foo', 'Bar']
        }
    },{
        dataIndex: 'b'
        ,text: 'Column B'
    },{
        dataIndex: 'c'
        ,text: 'Column C'
    }]

    ,store: {
        fields: ['a', 'b', 'c']
        ,autoLoad: true
        ,proxy: {
            type: 'memory'
            ,reader: 'array'
            ,data: [
                ['Foo', 1, 'Bar']
                ,['Bar', 2, 'Baz']
                ,['Baz', 1, 'Bar']
                ,['Bat', 2, 'Baz']
            ]
        }
    }

    ,tbar: [{
        text: 'Change list options'
        ,handler: function() {
            var grid = this.up('grid'),
                // forget about getFeature, I read the doc and found something!
                filterFeature = grid.filters,
                colAFilter = filterFeature.getFilter('a');

            // If the filter has never been used, it won't be available            
            if (!colAFilter) {
                // someone commented that this is the way to initialize filter
                filterFeature.view.headerCt.getMenu();
                colAFilter = filterFeature.getFilter('a');
            }

            // ok, we've got the ref, now let's try to recreate the menu
            colAFilter.menu = colAFilter.createMenu({
                options: ['Baz', 'Bat']
            });
        }
    }]
});
于 2013-06-05T16:15:07.920 に答える
0

私は同様の問題を解決していましたが、この質問への回答は私を大いに助けてくれました。ローカル リスト フィルター メニューは実際には遅延読み込み (クリックされたときにのみ作成) であり、グリッド ストアが別のデータでリロードされた場合にフィルター メニューをリロードするように設定する必要がありました。各リロード後にメニューを破棄することで解決したため、次のクリックでメニューが再作成されます:

var on_load = function() {
  var grid_header = me.gridPanel.filters.view.headerCt

  if (grid_header.menu) {
    grid_header.menu.destroy();
    grid_header.menu = null;  
  }
}
于 2016-01-18T18:01:56.960 に答える