2012-01-20 8 views
2

EXTJSグリッドを使用して、ページ区切り付きのチェックボックスグリッドリストを作成しています。ページのナビゲーションが実行されるときに、選択したレコードを覚えておく必要があります。EXTJS 3.3.3グリッド

詳細: 1)ページに移動:1と選択行1,2および3 2)次にページにナビゲート:2 3)バックページに来る:1 4)行1,2と3が既に選択されているものとして表示されます

この種の機能を処理するグリッドにはapiがありますか?

ありがとうございます。

答えて

2

ご回答ありがとうございます。私は、implementindでグリッド用のプラグインを使用して私のデザインを達成しました。プラグインは

Ext.namespace('Ext.ux.plugins'); 

Ext.ux.plugins.CheckBoxMemory = Ext.extend(Object, 
{ 
    constructor: function(config) 
    { 
     if (!config) 
     config = {}; 

     this.prefix = 'id_'; 
     this.items = {}; 
     this.idProperty = config.idProperty || 'id'; 
    }, 

    init: function(grid) 
    { 
     this.view = grid.getView() 
     this.store = grid.getStore(); 
     this.sm = grid.getSelectionModel(); 
     this.sm.on('rowselect', this.onSelect, this); 
     this.sm.on('rowdeselect', this.onDeselect, this); 
     this.store.on('clear', this.onClear, this); 
     this.view.on('refresh', this.restoreState, this); 
    }, 

    onSelect: function(sm, idx, rec) 
    { 
     this.items[this.getId(rec)] = true; 
    }, 

    onDeselect: function(sm, idx, rec) 
    { 
     delete this.items[this.getId(rec)]; 
    }, 

    restoreState: function() 
    { 
     var i = 0; 
     var sel = []; 
     this.store.each(function(rec) 
     { 
     var id = this.getId(rec); 
     if (this.items[id] === true) 
      sel.push(i); 

     ++i; 
     }, this); 
     if (sel.length > 0) 
     this.sm.selectRows(sel); 
    }, 

    onClear: function() 
    { 
     var sel = []; 
     this.items = {}; 
    }, 

    getId: function(rec) 
    { 
     return rec.get(this.idProperty); 
    } 
}); 

、ように見えます。このプラグインは、これはいくつかのいずれかを助け

Ext.grid.Gridpanel({ 
store: 'someStore', 
plugins: [new Ext.ux.plugins.CheckBoxMemory({idProperty: "recordID"})] 

}); 

ホープとしてgirdから呼び出されました。

+0

2007年4月、sencha.com/forumsのユーザーエバントはまったく同じように実装されました。ここはリンクです:https://www.sencha.com/forum/showthread.php?45723-problem-in-grid-pagination&highlight=getselectionmodel – JosefMadrid

1

あるとは思いません。選択したレコードのIDを別のストア/アレイに格納し、ページが変更されたときに選択内容を再適用する必要があります。

+0

私は、選択された行を配列に格納し、selectRows(Array)を使ってレコードを強調表示しました。しかし、ここに問題があります。ページ:1のID 1,2および3の行を選択してページ2に移動すると、ページ2の行1,2および3が選択されたとします。だから私は行IDを格納すると、ページ区切りグリッドでは適切ではないと思います。 – AJJ

+1

そのため、私は行IDではなくレコードIDについて話しています。データベースからのプライマリキーなど、強調表示されるレコードを不当に指示することがあるもの。 – Mchl

+0

ありがとうございました。私はあなたの答えを持って、それは動作します! – AJJ

0

これらのレコードを追跡するために、グローバルスコープにMixedCollectionオブジェクトを配置できます。これにより、異なるオブジェクトタイプのグローバル設定を保存することができます。

関連する問題