You need to sign in to do that
Don't have an account?
A better way to repeat a table over about 4times in VF???? Help
Hi:
I am repeating this table over and over again based on Term. So if the term changes and it pertains to the contact then repeat it with the information.
Can someone tell me a better way to do this:
<table> <tr> <td colspan="4" align="center">Term: 9.1</td></tr><tr> <td align="center">Subject Area</td> <td align="center">Total Courses<br/>Taken</td> <td align="center">CR Min Pass</td> <td align="center">Credits Earned</td> <td align="center">Gap</td> </tr> <apex:repeat value="{!queryResultsD}" var="de"> <apex:outputPanel rendered="{!de.TermD='9.1'}"> <tr> <td>{!de.on_TrackD}</td> <td>{!de.nosa}</td> <td>{!de.MinPassD}</td> <td>{!de.CED}</td> <td>{!de.CED-de.MinPassD}</td> </tr> </apex:outputPanel> </apex:repeat> </table> </td> <td valign="top"> <table> <tr> <td colspan="4" align="center">Term:9.2</td></tr><tr> <td align="center">Subject Area</td> <td align="center">Total Courses<br/>Taken</td> <td align="center">CR Min Pass</td> <td align="center">Credits Earned</td> <td align="center">Gap</td> </tr> <apex:repeat value="{!queryResultsD}" var="de"> <apex:outputPanel rendered="{!de.TermD='9.2'}"> <tr> <td>{!de.on_TrackD}</td> <td>{!de.nosa}</td> <td>{!de.MinPassD}</td> <td>{!de.CED}</td> <td>{!de.CED-de.MinPassD}</td> </tr> </apex:outputPanel> </apex:repeat>
Thanks
You could do something like this with a custom controller and wrapper class. Here's a similar thing I have going on, where it will look through a collection of class "FamilyLine", each instance of which has a list of class "line", which has the data displayed in the datatable. For each FamilyLine there is a summary row referring to a total amount.This will go through as many FamilyLines as I return from the controller.
<apex:repeat value="{!FamilyLines}" var="famline"> <apex:pageblocksection rendered="{!!isblank(famline.lines)}" title="Family {!famline.Family}" columns="1"> <apex:datatable styleclass="linetable" headerclass="lineheaders" rowclasses="odd, even" value="{!famline.lines}" var="line"> <apex:column styleclass="pcodecol" headervalue="Product Code" value="{!line.ProductCode}"/> <apex:column styleclass="amtcol" headervalue="Payments total"> <apex:outputfield value="{!line.query.Currency__c}"/> </apex:column> <apex:column styleclass="datecol" headervalue="Due Date"> <apex:outputfield value="{!line.query.Start_Date__c}"/> </apex:column> <apex:column styleclass="oppcol" headervalue="Opportunity"> <apex:outputlink value="/{!line.opp.id}" target="_opp">{!line.opp.Name}</apex:outputlink> </apex:column> </apex:datatable> </apex:pageblocksection> <table style="cellpadding: 5px;"> <tr><td class="familyname">{!famline.Family}</td><td class="familytotal" ><apex:outputfield value="{!famline.query.Currency__c}"/></td></tr> </table> <div style="width: 100%; border-bottom: 2px solid black;"/> </apex:repeat>
here is the class definition in the custom controller:
public class ProductLineItem { public String ProductCode { get ; set; } public String Family { get ; set; } public Double NetPayments { get ; set; } public Date DueDate { get ; set; } public Opportunity opp { get ; set; } public Query__c query { get ; set; } } public class FamilyLine { Public String Family { get ; set; } public list<ProductLineItem> lines { get ; set; } public Query__c query { get ; set; } //Currency__c refers to total of payments for this family public FamilyLine(String fam) { this.Family = fam; } }
Hope this helps.
Jeremy
All Answers
I have not done this before, but I believe you could approach this by using a component. You could create a component and instead of using standard html table use <apex:dataTable>. You could maybe parameterize it as well.
Also, since the table columns are the same, but only the result is different based on the term, you could do this all in the getter method of the queryResultsD. You could possibly check the value of de.TermD and do a different query based on the value. Hope that helps.
You could do something like this with a custom controller and wrapper class. Here's a similar thing I have going on, where it will look through a collection of class "FamilyLine", each instance of which has a list of class "line", which has the data displayed in the datatable. For each FamilyLine there is a summary row referring to a total amount.This will go through as many FamilyLines as I return from the controller.
<apex:repeat value="{!FamilyLines}" var="famline"> <apex:pageblocksection rendered="{!!isblank(famline.lines)}" title="Family {!famline.Family}" columns="1"> <apex:datatable styleclass="linetable" headerclass="lineheaders" rowclasses="odd, even" value="{!famline.lines}" var="line"> <apex:column styleclass="pcodecol" headervalue="Product Code" value="{!line.ProductCode}"/> <apex:column styleclass="amtcol" headervalue="Payments total"> <apex:outputfield value="{!line.query.Currency__c}"/> </apex:column> <apex:column styleclass="datecol" headervalue="Due Date"> <apex:outputfield value="{!line.query.Start_Date__c}"/> </apex:column> <apex:column styleclass="oppcol" headervalue="Opportunity"> <apex:outputlink value="/{!line.opp.id}" target="_opp">{!line.opp.Name}</apex:outputlink> </apex:column> </apex:datatable> </apex:pageblocksection> <table style="cellpadding: 5px;"> <tr><td class="familyname">{!famline.Family}</td><td class="familytotal" ><apex:outputfield value="{!famline.query.Currency__c}"/></td></tr> </table> <div style="width: 100%; border-bottom: 2px solid black;"/> </apex:repeat>
here is the class definition in the custom controller:
public class ProductLineItem { public String ProductCode { get ; set; } public String Family { get ; set; } public Double NetPayments { get ; set; } public Date DueDate { get ; set; } public Opportunity opp { get ; set; } public Query__c query { get ; set; } } public class FamilyLine { Public String Family { get ; set; } public list<ProductLineItem> lines { get ; set; } public Query__c query { get ; set; } //Currency__c refers to total of payments for this family public FamilyLine(String fam) { this.Family = fam; } }
Hope this helps.
Jeremy