How to display different column data as tool tip in ag grid pivot mode?

前端 未结 3 1189
轻奢々
轻奢々 2021-01-25 08:29
var ColDef = [{
    headerName: \"colA\",
    field: \'colA\',
    rowGroup: true
  },
  {
    headerName: \"colB\",
    field: \'colB\',
    pivot: true,
    enablePivo         


        
3条回答
  •  忘了有多久
    2021-01-25 08:57

    Not sure if there is good way for the grid to get the data in your scenario then, as your rows and columns are different than original model after pivot.

    Maybe you can consider retrieve this information outside of grid. Assume you also want some aggregated information displays in the tooltip, the tooltip function may eventually look like this:

    tooltip: params => {
      const country = params.node.key;
      const year = params.colDef.pivotKeys[0];
      const athletesWithNumbers = this.state.rowData
        .filter(d => d.year == year)
        .filter(d => d.country === country)
        .filter(d => d.gold > 0)
        .map(d => d.athlete + ': ' + d.gold);
      return athletesWithNumbers.join(', ');
    }
    

    See this plunker for what I am talking about - again, not sure if this is what you want but just an FYI.

提交回复
热议问题