You need to sign in to do that
Don't have an account?
Sujendran Sundarraj 8
how to use map in the vf page to display both key and value
Hi I have an requirement, that my client want me to create a report like vf page to group by the cases based on the status. the status value should be collapsable and on expanding the section it has to display the list of cases under that status. I have done half of it but still getting the issue to display the count of cases next to the status. can anyone please help me?
my code is
VF:
<apex:page controller="reporttobe" showHeader="false" >
<apex:pageBlock title="report area">
<apex:repeat value="{!result}" var="r">
<apex:pageBlockSection title="{!r}:Here I want to display the count of cases basec on status">
</apex:pageblockSection>
</apex:repeat>
</apex:pageBlock>
</apex:page>
Controller:
public class reporttobe {
public map<String, Decimal> result{get; set;}
list<AggregateResult> stlist;
public reporttobe(){
stlist = [select status stat, count(casenumber) caseno from case group by status];
result = new map<String, Decimal>();
for(aggregateresult aggResult: stlist){
result.put((String)aggResult.get('stat'), (Decimal)aggResult.get('caseno'));
}
system.debug(result);
}
}
Please help.
Thank you.
Regards,
Sujendran.
my code is
VF:
<apex:page controller="reporttobe" showHeader="false" >
<apex:pageBlock title="report area">
<apex:repeat value="{!result}" var="r">
<apex:pageBlockSection title="{!r}:Here I want to display the count of cases basec on status">
</apex:pageblockSection>
</apex:repeat>
</apex:pageBlock>
</apex:page>
Controller:
public class reporttobe {
public map<String, Decimal> result{get; set;}
list<AggregateResult> stlist;
public reporttobe(){
stlist = [select status stat, count(casenumber) caseno from case group by status];
result = new map<String, Decimal>();
for(aggregateresult aggResult: stlist){
result.put((String)aggResult.get('stat'), (Decimal)aggResult.get('caseno'));
}
system.debug(result);
}
}
Please help.
Thank you.
Regards,
Sujendran.
Please try using List
I hope you find the above solution helpful. If it does mark as best answer to help others too.
Thanks,
Ramesh D
Got it. Thank you so much.
When the user clicks the pageblock section, I need to pass the title(status ) to the controller. Can we pass the title to controller. Please help me to fix it.
Thank you.
Regards,
Sujendran.
Create a variable and assign value from VF Add a button something like this and assign the status to it
Thanks,
Ramesh D
try this below code:-
I have done this and it runs fine and change it according to your need.
-------------VF Page-------------
<apex:page controller="reporttobe" showHeader="false" >
<apex:pageBlock title="report area">
<apex:repeat value="{!result}" var="r">
<apex:pageBlockSection title="{!r}:Here I want to display the count of cases basec on status">
{!result[r]}
</apex:pageblockSection>
</apex:repeat>
</apex:pageBlock>
</apex:page>
-------------Apex Controller-----------------
public class reporttobe {
public map<String, Decimal> result{get; set;}
list<AggregateResult> stlist;
public reporttobe(){
stlist = [select status stat, count(casenumber) caseno from case group by status];
result = new map<String, Decimal>();
for(aggregateresult aggResult: stlist){
result.put((String)aggResult.get('stat'), (Decimal)aggResult.get('caseno'));
}
system.debug(result);
}
}
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha