簡體   English   中英

AG-Grid動態列標題文本

[英]AG-Grid dynamic column header text

這似乎很簡單,但事實證明並非如此。 由於某種原因, headerName被轉換為字符串,因此它不能成為函數。

我還嘗試了各種rendererheaderComponent函數,但是就像我說的那樣,我只想返回一個動態字符串,而不是覆蓋所有內容並必須重新實現它(例如,使用自定義標頭組件的情況)。

// I'm trying everything at this point, nothing renders out..
getHeaderCellTemplate: () => 'test 2',
headerCellTemplate: () => {
  // What I actually want to achieve:
  const currency = appModel.selectedCertificate().currency();
  return currency ? `Total Value (${currency})` : 'Total Value';
},
headerCellRenderer: HeaderCellRenderer,
headerComponent: HeaderCellRenderer,
cellRenderer: () => 'test 7',
headerRenderer: () => 'test 9',

我知道我可以將column def包裝在一個函數中,但這會非常低效,因為將在每次渲染時重新創建column def。

我希望這對您有用:

headerValueGetter: (params) => {
  const currency = appModel.selectedCertificate().currency();
  return currency ? `Total Value (${currency})` : 'Total Value';
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM