function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
virkvirk 

data table division

I want to divide a datatable or fully control the presentation of it in vf page if there are specified number of records in the list returned by the controller.If there are more reords I want the table to be shifted on next page which is done by default but only for list having records greater than 14 records. I am using th following code but it does not work for me because if the second data table is displayed it has the footer row at the end of each table but I want it to appear only on the last table if it is divided by default. Can someone please help how can I control the datatable presentation myself in the code.

<apex:component >
    <apex:attribute name="cotationTechniques" description="ControllerObj" type="Cotation_technique_Op__c[]" required="true"/>
    <apex:attribute name="sumCumac" description="Somme des cumacs" type="Cotation_technique_Op__c" required="true"/>
    <!--<apex:attribute name="rows"  description="wrapper rows" type="RowWrapper[]" required="true"/>-->
    <apex:attribute name="rows"  description="wrapper rows" type="RowWrapper" required="true"/>
<apex:repeat value="{!rows.mapCotTechOp}" var="key" rendered="{!cotationTechniques.size != null && cotationTechniques.size > 6 && cotationTechniques.size < 14}"> <apex:datatable value="{!rows.mapCotTechOp[key]}" var="cotTech" styleClass="fosts" border="1" cellpadding="0" cellspacing="1" style="page-break-inside:avoid !important;"> <apex:column > <apex:facet name="header">Référence Action Standard</apex:facet> <apex:outputField value="{!cotTech.fost__r.Name}"/> </apex:column> <apex:column > <apex:facet name="header">Volume de kWh cumac</apex:facet> <apex:facet name="footer"><apex:outputField rendered = "{!key = '1'}" value="{!sumCumac.PIL_PRI_CEE_reel__c}"/></apex:facet> <apex:outputField value="{!cotTech.PIL_PRI_CEE_reel__c}"/> </apex:column> </apex:datatable> </apex:repeat> <apex:datatable id="AIFTable" value="{!cotationTechniques}" var="cotTech" styleClass="fosts" border="1" cellpadding="0" cellspacing="1" style="page-break-inside:avoid !important;" rendered="{!NOT(cotationTechniques.size > 6 && cotationTechniques.size < 14)}" > <apex:column > <apex:facet name="header">Référence Action Standard</apex:facet> <apex:outputField value="{!cotTech.fost__r.Name}"/> </apex:column> <apex:column > <apex:facet name="header">Volume de kWh cumac</apex:facet> <apex:facet name="footer"><apex:outputField value="{!sumCumac.PIL_PRI_CEE_reel__c}"/></apex:facet> <apex:outputField value="{!cotTech.PIL_PRI_CEE_reel__c}"/> </apex:column> </apex:datatable></apex:component>

If there are 6 records retuened in the list then it is displayed on the same page but if there are more than 6 and less than 14 records it shifts to next page and leaves the previous page empty. This is why I have put a condition on the first part if there are more than 6 and less than 14  records data table is divided in two tables else it is displayed as default. In default case if it has more than 14 records it is displayed good on two pages but the footer is shown on two tables rather I want footer only on second page or where the list ends.

Also the page is rendered as pdf.

Thanks.