2012-02-07 50 views
1

我創建了Ext.grid.Panel,現在我需要對服務器上計算的數據進行摘要。我在該網格中沒有分組。Exjts4網格遠程摘要(無分組)

在功能ftype: 'summary'沒有像'remoteRoot'這樣的屬性。 有沒有機會創建這個總結與分組?

+0

那麼rowexpander呢? – Hadas 2012-02-07 09:21:16

+0

它允許從AJAX請求中獲取數據嗎?我沒有找到這樣的例子。 – BlackLine 2012-02-07 11:17:10

+0

無論如何,我需要一個彙總行,而不是可擴展的額外行 – BlackLine 2012-02-07 11:18:20

回答

1

您必須擴展/覆蓋類。這是一個基於AbstractSummary.js的示例,應該進行優化。

// usage in grid: 
{ 
    ftype : 'summary', 
    remoteRoot : 'summary' 
} 

//response from server 
{ 
    data : [] // our standard data 
    summary : { 
     summaryField : 123123 
    } 
} 

// our class 
Ext.define('w3desApp.grid.feature.Summary', { 
override : 'Ext.grid.feature.Summary', 
getSummary: function(store, type, field, group) { 
    var reader = store.proxy.reader; 
    if (this.remoteRoot && reader.rawData) { 
     // reset reader root and rebuild extractors to extract summaries data 
     root = reader.root; 
     reader.root = this.remoteRoot; 
     reader.buildExtractors(true); 
     summaryRow = reader.getRoot(reader.rawData); 
     // restore initial reader configuration 
     reader.root = root; 
     reader.buildExtractors(true); 
     if (typeof summaryRow[field] != 'undefined') { 
      return summaryRow[field]; 
     } 

     return ''; 
    } 

    return this.callParent(arguments); 
    } 
});