You need to sign in to do that
Don't have an account?
Different column headers for different columns in apex:repeat
<apex:page standardController="opportunity" tabStyle="opportunity" extensions="mySecondController"> <style> .locationError { color: blue; font-weight: strong;} </style> <apex:form > <!--<apex:messages /--> <apex:pageBlock title="opp line items" mode="edit"> <apex:pageMessages /> <apex:pageBlockButtons location="top" > <apex:commandButton value="Save" action="{!saveChanges}" rerender="main" status="ajaxStatus"/> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> <apex:actionStatus id="ajaxStatus" startText="Updating line items..."> </apex:actionStatus> <!--<apex:outputPanel layout="block" style="overflow:auto;width=750px;height=250px">--> <!--div style="overflow:auto;width=750px;height=250px"--> <apex:pageBlockTable value="{!secondcontroller}" var="oli"> <apex:column id="thename" headerValue="Name"> {!oli.transcript2.PriceBookEntry.Product2.Name} </apex:column> <apex:column > <apex:facet name="header"><b>Schedules</b></apex:facet> <apex:repeat value="{!oli.trainee2}" var="b"> <apex:inputField value="{!b.quantity}"/> </apex:repeat> </apex:column> <apex:column title="This is the total quantity" headerValue="Quantity Sum"> {!oli.transcript2.Quantity} </apex:column> <apex:column title="This is the total quantity" headerValue="Quantity{!oli.tr2.Unit_Of_Measure__c}" footervalue="{!total.quantity}"> <apex:inputField value="{!oli.transcript2.quantity}" id="Custon_validation"/> </apex:column> <apex:column > {!oli.tr2.Unit_Of_Measure__c} </apex:column> <apex:column headerValue="Unit Sales Price" > <apex:inputField value="{!oli.transcript2.UnitPrice}"/> </apex:column> <apex:column headerValue="LineDesc" > <apex:inputField value="{!oli.transcript2.description}"/> </apex:column> <apex:message for="Custon_validation" styleClass="locationError"/><p/> </apex:pageBlockTable> <!--</apex:outputPanel>--> </apex:pageBlock> </apex:form> </apex:page>
Hi there,
I have a requirement where I have to display different column header names for the different columns generated using apex:repeat in a visualforce table.I have not been able to figure out how to do this.Any help would be much appreciated.
I am using apex:repeat for fetching the values of the opportunitylineitemschedules against each opportunitylineitem in the table.I am getting the values correctly.But for each opportunitylineitemschedule column I need a header name as the schedule date for the opplineitemschedule(which btw wud remain same for each column)>Currently I can show only one header name using facet header but I want to be able to show different names for different columns.
Here's my VF page:
I'm a little confused about what you are actually trying to achieve here.
The only repeat I can see in your page is inside a column. This will cause the contents of a single cell in the column to be the full output from the repeat.
Are you trying to display two distinct types of data inside a single table?
This is trivially painful-- I actually developed this for a project I just deployed recently. You have to actually render the columns yourself, like so:
Controller:
public class theController {
public class theRecordSet {
public List<String> headers { get; set; }
public List<List<String>> values { get; set; }
}
public theRecordSet record { get; set; }
public theController() {
record = new theRecordSet();
record.headers=new list<string>();
record.values=new list<list<string>>();
}
}
Page:
<apex:page controller="theController"> <table> <tr> <apex:repeat value="{!record.headers}" var="header"> <th>{!header}</th> </apex:repeat> </tr> <apex:repeat value="{!record.values}" var="values"> <tr> <apex:repeat value="{!values}" var="value"> <td>{!value}</td> </apex:repeat> </tr> </apex:repeat> </table> </apex:page>
one formatting issue when mixing apex commands with html tables is that the apex commands generate SPAN tags, and depending on your situation, these can wreak havoc.
no simple answers, but if you are getting ghost formatting problems (like extra or missing <td>s) the cut & past the browser output into a regular html editor and check out the code.
@sfdcfox: Glad to come accros this post. Can you please look at my post: http://boards.developerforce.com/t5/General-Development/Dynamic-quot-headerValue-quot-binding-in-VF-page/m-p/487387#M74337
Do you think I am in the same boat here? I am not able to dynamically determine column headers. I tried apex:repeat and that seems to be working. Actually this is the only solution that has given me some hopes.
regards
Mitesh