3

I hope someone can help me.

This my code basically I am creating a quote PDF. In this case when there is no training products the table should be rendered in the PDF. And I am able to hide every single line with this logic rendered="{!HWLineItems.size>0}". But the issue is that in the header remain a blank line with the table format (background colour number of columns). How can I remove that format? I tried with outputpannel but then is removing the format but unfortunately is also removing the format when the query is not empty.

Could you help me?

Thanks in advance

        <apex:page standardController="Quote" action="{!populatePriceOnQuote}" extensions="QuotePDFController" applyHtmlTag="false" showHeader="false"  renderAs="pdf">

            <head>
            <style type="text/css" >

            @page { 
                size: letter portrait;

                margin-left: 2cm;
                margin-right: 2cm;
                margin-top: 4cm;
                margin-bottom: 2cm;
                font-family: 'SansSerif';
                @top-left {
                    content: element(header_left);
                }

                @top-center {
                    content: element(header_center);
                }

                @top-right {
                    content: element(header_right);
                }

                @bottom-left {
                    content: element(footer_left);
                }

                @bottom-center {
                    content: element(footer_center);
                }

                @bottom-right {
                    content: counter(page) " ("  counter(pages) ")";
                }
            }


        .header_left {
            position: running(header_left);
            margin-bottom:10px;
            color: #A0A0A0;
            font-size: 10pt;
            font-family: 'SansSerif';

        }



        .header_center{
            position: running(header_center);
            font-family: 'SansSerif';
        }

        .header_right {
            text-align: right;
            position: running(header_right);
            font-family: 'SansSerif';
        }

        .rayHeader1 {
            font-size: 13pt;
            color: #365F91;
            font-weight: bold;
            font-family: 'SansSerif';
        }

        .rayHeader2 {
            font-size: 10pt;
            color: #365F91;
            font-weight: bold;
            font-family: 'SansSerif';
        }

        .rayBody {
            font-size: 10pt;
            page-break-after: always;
            font-family: 'SansSerif';
        }

        .rayBody2 {
            font-size: 10pt;
            font-family: 'SansSerif';
        }

        #quotePricing {
            font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
            width: 100%;
            border-collapse: collapse;

        }

        #quotePricing td, #quotePricing th {
            font-size: 1em;
            border: 1px solid #4F81BD;
            p
            ing: 3px 7px 2px 7px;
        }

        #quotePricing th {
            font-size: 1.1em;
            text-align: left;
            padding-top: 5px;
            padding-bottom: 4px;
            background-color: #4F81BD;
            color: #ffffff;
        }

        #quotePricing tr.alt td {
            color: #000000;
            background-color: #DBE5F1;
        }


        .footer_left {
            text-align: left;
            position: running(footer_left);
        }

        .footer_center {
            text-align: center;
            position: running(footer_center);
        }

        .footer_right {
            text-align: right;
            font-family: 'SansSerif';
            position: running(footer_right);
        }

        .pageNumber:before {
            content: counter(page); 
        }

        .pageCount:before {
            content: counter(pages);  
        }

        .rayTD1 {

            color: #005380;
            font-weight: bold;
            padding: 2px;

        }




        .rayTerms {

            color: #365F91;
            font-weight: bold;
        }

        .rayTable {
            width: 100%;
            border-collapse: collapse;
        }

        .rayTable td {
            font-size: 1em;
            border: 0.5px solid #4F81BD;
            padding: 3px 7px 2px 7px;
        }




        </style>
        </head> 

    <table id="quotePricing">
<!--<apex:variable value="{!1}" var="rowNum"/>-->
   <thead  >
       <th width="12%" ><apex:outputText rendered="{!TrainingLineItems.size>0}">Qty</apex:outputText></th>
       <th ><apex:outputText rendered="{!TrainingLineItems.size>0}">Application/Product</apex:outputText></th>
       <th  ><apex:outputText rendered="{!TrainingLineItems.size>0}">Comment</apex:outputText></th>
   </thead>
<apex:repeat value="{!TrainingLineItems}" var="line">
<apex:variable var="v" value="" rendered="{!TrainingLineItems.size>0}">
   <tr class="alt">
    <td width="12%"><apex:outputText value="{0, number, ###,###,##0}" rendered="{!TrainingLineItems.size>0}"><apex:param value="{!line.Quantity}" /></apex:outputText></td>
     <td><apex:OutputField value="{!line.Prod_Name__c}" rendered="{!TrainingLineItems.size>0}"></apex:OutputField></td>  
     <td><apex:OutputField value="{!line.Description}" rendered="{!TrainingLineItems.size>0}"></apex:OutputField></td>
  </tr>
  <!--<apex:variable var="rowNum" value="{!rowNum + 1}"/>-->
  </apex:variable>
</apex:repeat>
</table>

1 Answer 1

1

There's a couple of different ways of handling this, both involve modifying your controller to detect when the wrapper list of is zero length. One is to wrap the wrapper in a 2nd wrapper that contains a variable with a boolean value of whether the inner wrapper is greater than zero. If false, then the outer wrapper uses a repeat located outside the table to tell the table not to render at all (render = false). If true, it tells it to render (render = true).

An even simpler method is to simply use another Boolean variable that's assigned to the Boolean I just mentioned. Then wrap the entire table in a Div tag. Use the value of the Boolean to set render=true or render=false for the Div. That way, either the table renders or it doesn't. No need to process the wrapper at all if it has no records.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .