2011-10-24 37 views
3

在這個例子中: http://dev.sencha.com/deploy/ext-4.0.2a/examples/grid/buffer-grid.htmlEXT JS。你如何加載緩衝滾動示例中的所有行?

我想添加名爲「閱讀所有」的按鈕,並且點擊時,所有的行應該被加載所以沒有更多的緩衝。

當用戶想要更好地控制所有內容而無需等待緩衝區在特殊情況下完成時,這非常有用。

謝謝,任何幫助表示讚賞

+0

由於緩衝功能非常適用,我很想知道更多關於您的特殊情況的信息。但是,您可能會嘗試使用無緩衝存儲重新顯示網格(如果需要,只需等待它加載)。 –

+0

嗯,我想給用戶選擇所有行,當緩衝處於活動狀態時,他們不能選擇所有行,因此它們不能全部移除,很難上下移動並選擇單個行然後刪除它們。 – Yasser1984

回答

1

使用與共同模型的兩個商店。

第一個是當前的(有緩衝,分頁等)。第二個是普通商店,沒有緩衝,分頁等。當你點擊'全部閱讀'時,只需將每條記錄加載到第二商店並用新數據更新第一條記錄。

下面是一個例子:

Ext.create ('Ext.grid.Panel', { 
    renderTo: Ext.getBody() , 
    width: 300 , 
    height: 300 , 
    store: bufferingStore , 

    columns: [ ... ] , 

    tbar: { 
     items: [{ 
      xtype: 'button' , 
      text: 'Read all' , 
      handler: function (btn) { 
       // Here's the call to retrieve all records 
       // Also you can do it with 'autoLoad: true' param 
       normalStore.load(); 

       // Then, flush the bufferingStore, currently use by the grid 
       bufferingStore.removeAll(); 

       // Populate bufferingStore with normalStore 
       normalStore.each (function (record) { 
        bufferingStore.add (record); 
       }); 
      } 
     }] 
    } 
}); 

normalStore和bufferingStore具有相同的模型,但是normalStore都會有不同的源檢索每個記錄。