Author Topic: how to get the pivot grid cell value of a group cols?  (Read 2838 times)

徐雪峰

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 48
    • View Profile
how to get the pivot grid cell value of a group cols?
« on: July 20, 2020, 03:29:55 pm »
i want to get the pivot grid cell's value of one kind of group cols.
because i want to sum them by my formular.
is there any way to do it ?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6263
    • View Profile
Re: how to get the pivot grid cell value of a group cols?
« Reply #1 on: July 21, 2020, 10:25:05 pm »
pivot grid cell value can be obtained by

Code: [Select]
grid.pageData()[ rowIndx ][ dataIndx ]

However you don't need to access individual cells because custom aggregate can be conveniently written by adding a custom method to pq.aggregate

https://paramquery.com/pro/api#method-aggregate
« Last Edit: July 21, 2020, 10:34:49 pm by paramvir »

徐雪峰

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 48
    • View Profile
Re: how to get the pivot grid cell value of a group cols?
« Reply #2 on: July 22, 2020, 12:26:45 pm »
thank you ,i'll try it. if success, i think i will very happy.

徐雪峰

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 48
    • View Profile
Re: how to get the pivot grid cell value of a group cols?
« Reply #3 on: July 22, 2020, 12:38:26 pm »
//define custom aggregate "all", now it can be used as column.summary.type
agg.all = function(arr, col){
    return "Sum: " + format( agg.sum(arr, col) )
        +", Max: " + format( agg.max(arr, col) )
        +", Min: " + format( agg.min(arr, col) );
};
can you tell me the meaning of paramater arr and col?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6263
    • View Profile
Re: how to get the pivot grid cell value of a group cols?
« Reply #4 on: July 22, 2020, 09:39:30 pm »
Please refer API for meaning of arguments:

https://paramquery.com/pro/api#method-aggregate

徐雪峰

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 48
    • View Profile
Re: how to get the pivot grid cell value of a group cols?
« Reply #5 on: July 23, 2020, 11:02:17 am »
i set the pivotColsTotal: 'hideifOpen',but can not hide the last summay column.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6263
    • View Profile
Re: how to get the pivot grid cell value of a group cols?
« Reply #6 on: July 23, 2020, 07:51:28 pm »
Since last summary column has no parent column, "hideifOpen" is not applicable to it.

It can be hidden in the pivotCM event by adding hidden: true property to it.

徐雪峰

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 48
    • View Profile
Re: how to get the pivot grid cell value of a group cols?
« Reply #7 on: July 27, 2020, 04:33:14 pm »
thanks.