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

前端 未结 3 1153
轻奢々
轻奢々 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:36

    just use tooltipValueGetter

    {
       field: 'message',
       headerName: 'Message',
       headerTooltip: 'Message',
       width: 110,
       filter: 'agSetColumnFilter',
       tooltipValueGetter: (params) =>  `${params.value} some text`
    }
    

    or just use the same method for tooltipValueGetter

    UPDATE:

    Okay, I understood

    but it also easy

    Ag-grid has property tooltipField - where you can choose any field from grid

    For example here - in the column of 'sport' I am showing tooltip of the previous column

    Example: https://plnkr.co/edit/zNbMPT5HOB9yqI08

    OR

    You can easily manipulate with data for each field by tooltipValueGetter with next construction:

    tooltipValueGetter: function(params) {  
      return `Country: ${params.data.country}, Athlete: ${params.data.athlete}, Sport: ${params.data.sport}`;
    },
    

    Example: https://plnkr.co/edit/zNbMPT5HOB9yqI08

    Result:

    UPDATE 2

    Hey Man! I do not understand was is wrong

    I just used your code snippet and my solution

    And it works as you want

    Example: https://plnkr.co/edit/zNbMPT5HOB9yqI08

    UPDATE 3

    A little bit of manipulation and I can get the data

    { field: 'gold', aggFunc: 'sum',
        tooltipValueGetter: function(params) {  
        var model = params.api.getDisplayedRowAtIndex(params.rowIndex);
        return model.allLeafChildren[0].data.silver;
      },
    },
    

    The Last: https://plnkr.co/edit/9qtYjkngKJg6Ihwb?preview

提交回复
热议问题