You need to sign in to do that
Don't have an account?

Represent multiple records in a single line in a visualforce page
Hi,
I have been able to get a visualforce page working to display the results of a query with one row for each record but would like to see if it is possible to format the data differently so that I can group by a field and then display all of the values in another field in the rest of the row. An example would be:
FIELD 1 FIELD 2 FIELD 3
A 1 Red
A 2 Yellow
B 2 Yellow
B 1 Red
B 3 Green
To be displayed in separate cells as:
A 1(in red) 2(in yellow)
B 2(in yellow) 1(in red) 3(in green)
Thanks in advance for any assistance.
I have been able to get a visualforce page working to display the results of a query with one row for each record but would like to see if it is possible to format the data differently so that I can group by a field and then display all of the values in another field in the rest of the row. An example would be:
FIELD 1 FIELD 2 FIELD 3
A 1 Red
A 2 Yellow
B 2 Yellow
B 1 Red
B 3 Green
To be displayed in separate cells as:
A 1(in red) 2(in yellow)
B 2(in yellow) 1(in red) 3(in green)
Thanks in advance for any assistance.
You might could use an AggregateResult and loop through the rusults and return how you like......
Thanks for the response. However, I do not want to sum the data in Field 2 since it would be possible for me to get two records with the same values in Field 1 and Field 3 but different values in Field 2 that I would like to see separately when displayed so not sure that the aggregate function produces the desired output.
Sam.
So if you had a table with the data below the soql would give you the soql result. Are you wanting the soql result or something like the other result. The soql reuslt would just be the first step the next would be to loop through in and format to pass back to the VF page.
field1__c field2__c field3__c
A 3 Yellow
A 2 Yellow
A 1 Red
B 3 Green
B 2 Yellow
B 1 Red
SOQL Result:
field1__c Sum field3__c
A 1 Red
A 5 Yellow
B 1 Red
B 3 Green
B 2 Yellow
Other Result
A 1(in Red) 2(in Yelow) 3(in Yellow)
Thanks for the response. My main challenge here is how to render these results in the VF page since I can get rthe data displaying one record at a time but want to have multiple records being displayed on a signle line, all grouped by Field 1.
Thanks,
Sam.