Author Topic: Aggregate of selected rows  (Read 1456 times)

j.jose

  • Newbie
  • *
  • Posts: 8
    • View Profile
Aggregate of selected rows
« on: October 06, 2021, 07:54:46 pm »
Hallo Support-Team,

Is there any workaround/option to add only the values in a column of selected rows?

Case-Scenario
There are some rows that are already grouped and the SUM(Expenses) is shown as aggregate.
From this, the user selects / clicks on two rows only and would like to see the  SUM(Expenses) of these two rows only.
Would this be possible?

Please guide me to an example where this option is implemented.

Thanking you in advance!

Best regards,
Jiny

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6125
    • View Profile
Re: Aggregate of selected rows
« Reply #1 on: October 13, 2021, 02:29:13 pm »
yes it's possible to do so by defining custom aggregates.

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

Selection state of a row ( when selectionModel.type = 'row' ) can be detected from pq_rowselect metadata of a row.

Code: [Select]
if( rowData.pq_rowselect ){
  //use this row in custom aggregate.
}