How to do grouping and aggregation in jsReport?
-
I want to generate a report with grouping on particular fields.
e.g.
I have following data:
[{
id: 1,
message: "hello"
},
{
id: 2,
message: "hello"
},
{
id: 3,
message: "test"
}
]Now, I want to group on the basis of message. Output should be something like this:
Message Sum
hello 2
test 1
-
The data reprocessing is common task which is done using jsreport custom script
beforeRender
hook.
ThebeforeRender
hook lets you run a javascript function and modify the input data as you want.
Please check the documentation
https://jsreport.net/learn/scriptsThe grouping of data is a common task that can be done in many ways using javascript.
See one of the online examples.
-
Is there any extension available which do such tasks like grouping and aggregation?
Is there any examples available for these functions:
https://www.jsreports.com/docs/functions/#aggregates
-
You link documentation of a completely different product, which isn't active actually for a long time. Our documentation is here
https://jsreport.net/learn
-
Oops. This is kind of confusing.
Scripts is the only way of grouping and aggregating data. Right?
-
You can also group data upfront before sending it to the jsreport.
Something wrong with the script approach?
You can write any javascript there, so it is the most powerful and flexible solution you can get.
-
Thanks @jan_blaha .
There is nothing wrong with script approach. I was just confirming.