0

I have an apex:datatable that lists opportunityLineItems. I want to render the columns based on the value of the lineitem field Product_Type__c and then add a break in between each group. I am able to get the render to work, but cannot figure out how to add a break in between. (I've tried using <br/>, tried multiple data tables wrapped in outputpanels, I even tried using repeat instead, but that was even more limited).

Here are a couple examples of what I'm trying (but not getting the result I need):

FIRST ATTEMPT:

 <apex:dataTable value="{!Opportunity.opportunityLineItems}" rendered="{!Opportunity.Mandatory__c}" var="OP" width="98.7%">
      <apex:column rendered="{!OP.Product_Type__c = 'Mandatory'}" value="{!OP.ProductCode}" styleClass="tbl_bdr tal" style="width:10%;"></apex:column>
  </apex:dataTable>    

 <apex:dataTable value="{!Opportunity.opportunityLineItems}" rendered="{!Opportunity.Base__c}" var="OP" width="98.7%">
     <apex:column rendered="{!OP.Product_Type__c = 'Base'}" value="{!OP.ProductCode}" styleClass="tbl_bdr tal" style="width:10%;"></apex:column>
  </apex:dataTable>    

SECOND ATTEMPT:

 <apex:dataTable value="{!Opportunity.opportunityLineItems}" rendered="{!Opportunity.Mandatory__c}" var="OP" width="98.7%">
     <apex:column rendered="{!OP.Product_Type__c = 'Mandatory'}" value="{!OP.ProductCode}" styleClass="tbl_bdr tal" style="width:10%;"></apex:column>
     <br/>
     <apex:column rendered="{!OP.Product_Type__c = 'Base'}" value="{!OP.ProductCode}" styleClass="tbl_bdr tal" style="width:10%;"></apex:column>
  </apex:dataTable>   
  • 2
    I don't think you can do that. <apex:column>'s are turned into parts of a <table> and tables don't allow elements to fit in between columns. You should look into using CSS to add a space or border between the generated table elements. – battery.cord Aug 14 at 17:23
  • 1
    You have to add empty rows. – Adrian Larson Aug 14 at 17:26
  • You'd have to process the data in JavaScript, or use a custom controller. You can't do this in markup. – sfdcfox Aug 14 at 17:26
  • How do I add empty rows? – Heather Aug 14 at 18:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.