function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MCPMCP 

Datatable grouping of data rows

Hi there. I'm trying to create a page in VisualForce that would simulate what a Crystal Reports would do.
One thing I'm still researching is how I could group the rows in a data table based on a field in that data table.
Is this possible in VF?
 
Let's say one of the fields in the datatable is "period". I want to display all the rows with period value of 1,
so I could show the total amount (another field in the datatable) of the  rows in a footer.
Then I want to do the same thing for period 2.
 
Any suggestion would be greatly appreciated. Thanks!!!
 
David VPDavid VP
The datatable is a component that basically just displays fields in objects from an array.
As far as I know there's no extra 'grouping' intelligence added to it.

A solution could be to create your own 'row' object with col1, col2, col3, ... properties.
Then loop over your source data in Apex; do all the sums, grouping etc .. that you need and drop the aggregated results in row objects and into a List.

Use that List to bind to your datatable.


I amuse that Reports don't cover your needs ?

If you only need to create one report you could code it but if you need this a lot (and the standard reporting functionality isn't enough) then you could consider looking at some of the reporting tools on the AppExchange.


David