2011-06-04 90 views
2

任何人都知道如何將渲染器附加到ExtJS4中的網格分組標題中?在ExtJS3我有以下工作代碼,它返回「過去」事件是否已經完成(「Y」),或「即將」如果沒有完成:ExtJS4網格分組標題渲染器 - 如何指定?

function fmt_group_heading(groupVal) { 
    if (groupVal === 'Y') { 
     return 'Past'; 
    } else { 
     return 'Upcoming'; 
    } 
} 

    // create the Grid 
    var fitGrid = new Ext.grid.GridPanel({ 
     store: fitGroupingStore, 
     columns: [ 
     {header: "ID", dataIndex: 'id', hidden: true }, 
       {header: 'Event', width:320, dataIndex: 'event',    
          renderer:fmt_event_description}, 
       {header: 'Events', dataIndex: 'completed', hidden: true, 
          renderer: fmt_group_heading } 
    ], 
    stripeRows: true, 
    // config options for stateful behavior 
    stateful: true, 
    stateId: 'grid', 
hideHeaders: true, 
view: new Ext.grid.GroupingView({ 
    groupRenderer: 'completed', 
    forceFit: true 
})  
}); 

ExtJS4提供網格分組,但我不瞭解如何更改組文本的輸出。 Ext.grid.feature.Grouping的'groupHeaderTpl'屬性似乎只將原始字段值從商店中讀取。

this.groupingFeature = Ext.create('Ext.grid.feature.Grouping', { 
     groupHeaderTpl: 'Group: {completed}' 
    }); 

    // create the Grid 
    this.fitnessGrid = new Ext.grid.Panel({ 
     store: this.fitnessEventStore, 
     features: [this.groupingFeature], 
      // etc....... 

回答

1

嘗試不服這樣的:

groupHeaderTpl: 「 - {[fmt_group_heading(values.name)]} ({rows.length} 項{[values.rows.length> 1 ?「s」: 「」]})'

1

groupHeaderTpl要求您在撰寫模板時使用{name}。它只會使用groupField提供的值。

See the Docs

0

試試這個:

groupHeaderTpl: '{[values.rows[0].completed]}'