Author Topic: aggregate of column based on values displayed in cells  (Read 967 times)

mikep

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 163
    • View Profile
aggregate of column based on values displayed in cells
« on: August 27, 2021, 06:03:01 pm »
thank you. Is there any way to get the aggregate column to sum based on the values displayed in the cell or I this another approach you could recommend? I'm guessing not, but wanted to ask 1 more time.
 

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: aggregate of column based on values displayed in cells
« Reply #1 on: August 29, 2021, 11:05:43 am »
summary takes values directly from data and doesn't consider the values rendered in cells.

However your requirement can be met with any of the following ways:

1). using getters/setters

define another field e.g., _month1 in rowData.

Code: [Select]
_month1: '339938.0,red,hovertext',

and use getters/setters to extract data values from _month1

Code: [Select]
origData.forEach(function(rd) {
  Object.defineProperty(rd, 'month1', {
    enumerable: true,
    get() {
      return this._month1.split(",")[0];
    },
    set(val){             
    var arr = this._month1.split(",");
    this._month1 = [val, arr[1], arr[2]].join(",");
    }
  })
})

https://jsfiddle.net/7g2tnu1k/

2). without getters/setters

define value in month1 while color, hovertext in another field _month1:

Code: [Select]
month1: 339938.0,
_month1: 'red,hovertext',

https://jsfiddle.net/5e9whfkg/

3. use of meta data in rows i.e., pq_cellstyle and pq_cellattr

Code: [Select]
{
              rank: 5,             
              company: 'Exxon Mobil test',
              month1: 339938.0,
              month2: 36130.0,
              month3: 333333.0,
              pq_cellstyle: {month1: {'background-color': 'red'}},
              pq_cellattr: {month1: 'title="hovertext"'}
}
« Last Edit: August 29, 2021, 11:44:33 pm by paramvir »