2013-04-10 112 views
2

關於以下網格分組示例。如果沒有數據返回第一條記錄,如何顯示第一組爲(0個國家/地區)。Extjs網格分組 - 設置默認標頭/值

目前,如果沒有記錄,第一組未出現

enter image description here

我需要做的是,表明有(0)計數,而不僅僅是讓它消失第一組是什麼。有沒有辦法顯示組頭,即使沒有數據,如默認頭或什麼?有任何想法嗎?我需要爲所有的4頭

更新爲此

Ext.require(['Ext.data.*', 'Ext.grid.*']); 
Ext.onReady(function() { 
Ext.define('Country', { 
    extend: 'Ext.data.Model', 
    fields: ['name'] 
}); 

var Country = Ext.create('Ext.data.Store', { 
    storeId: 'country', 
    model: 'Country', 
    groupField: 'countryName', 
    proxy: { 
      type: 'ajax', 
      scope: this, 
      url: 'myExtjsApp/ExtjsGetRecord', 
      reader: { 
       type: 'json', 
       root: 'data' 
      } 
     } 
}); 

var groupingFeature = Ext.create('Ext.grid.feature.Grouping',{ 
    groupHeaderTpl: '{name} ({rows.length} Item{[values.rows.length > 1 ? "s" : ""]})' 
}); 

var grid = Ext.create('Ext.grid.Panel', { 
    renderTo: Ext.getBody(), 
    collapsible: true, 
    iconCls: 'icon-grid', 
    frame: true, 
    store: Country, 
    width: 600, 
    height: 400, 
    title: 'Country', 
    features: [groupingFeature], 
    columns: [{ 
     text: 'Country', 
     flex: 1, 
     dataIndex: 'name' 
    }] 
}); 
}); 
+0

你也可以添加你的json數據饋送。 (或其中的一部分) – Dawesi 2013-12-03 15:17:32

+0

我看到你在這裏得到這個答案讓你的代碼:http://stackoverflow.com/questions/7521567/how-to-show-grouped-value-in-extjs-4-grid-groupheader – Dawesi 2013-12-03 15:20:31

回答