+ Start a Discussion
baller4life7baller4life7 

TABLE with dynamic value

Heu guys,

I was wondering whether there's a possibility to have a function with a parameter as a value for an apex:datatable...

My attempt would be something like the following code, but functions don't seem to be accepted as a value...

 

<apex:repeat value="{!paramters}" var="parameter">
<apex:dataTable value="function({!parameter})" var="item"> ... </apex:dataTable>
</apex:repeat>

 My goal is to have 4 tables with opportunities for each quarter of a year and I want to avoid writing redundant code. The function would return the opportunities and the parameter would be the number of the quarter (1,2,3,4)

Best Answer chosen by Admin (Salesforce Developers) 
Shashikant SharmaShashikant Sharma

You should do it like

 

Create a map in controller

 

 

public MAP<Integer , List<Opportunity>> mapListForQuarter {get;set;}

 

fill it properly for each quarter and 

 

 

<apex:repeat value="{!paramters}" var="parameter">
<apex:dataTable value="{mapListForQuarter[parameter]}" var="item">
...
</apex:dataTable>
</apex:repeat>

 Please ask if any issue in it.


All Answers

Shashikant SharmaShashikant Sharma

You should do it like

 

Create a map in controller

 

 

public MAP<Integer , List<Opportunity>> mapListForQuarter {get;set;}

 

fill it properly for each quarter and 

 

 

<apex:repeat value="{!paramters}" var="parameter">
<apex:dataTable value="{mapListForQuarter[parameter]}" var="item">
...
</apex:dataTable>
</apex:repeat>

 Please ask if any issue in it.


This was selected as the best answer
baller4life7baller4life7

Good idea. Works perfect!

Shashikant: Thank you once again!