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

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

        var ColDef = [{
            headerName: "colA",
            field: 'colA',
            rowGroup: true
          },
          {
            headerName: "colB",
            field: 'colB',
            pivot: true,
            enablePivot: true
          },
          {
            headerName: "colC",
            field: 'colC',
            rowGroup: true
          },
          {
            field: 'colD',
            aggFunc: 'last',
        tooltipValueGetter: commentTooltipValueGetter
          },
          {
            field: 'comment'
          },
          {
            field: 'colF'
          }
        ];
    
    
        function commentTooltipValueGetter(params) {
        const colB = params.colDef.pivotKeys[0];
        var model = params.api.getDisplayedRowAtIndex(params.rowIndex);
        for (var i = 0; i < model.allLeafChildren.length ; i++) {
            if (model.allLeafChildren[i].data.colB=== colB) {
              return model.allLeafChildren[i].data.comments;
                                                           }
                                                 }
      }
    

    This is what i had to do for my question. It is combination of answers from @wctiger and @shuts below. So please also refer them for more context

提交回复
热议问题