-1

So i've got the table below, i want columns to be automatically removed upon the page loading, i should say i am rendering it as PDF. How would i remove the columns that have no data including the header.

 <table border="1" cellpadding="6" width="100%" class = "table1">
                    <thead>
                     <tr>
                        <th title="Field #1">test 1</th>
                        <th title="Field #2">test 2</th>
                        <th title="Field #3">test 3</th>
                     </tr>
                    </thead>
                <apex:repeat value="{!qli}" var="opp">
                    <tbody> 
                    <tr>
                        <td>
                            <apex:outputText value="{!opp.test1}" />
                        </td>
                        <td>
                            <apex:outputText value="{!opp.test2}" />
                        </td>
                        <td>
                            <apex:outputText value="{!opp.test3}" />
                        </td>
                    </tr>
                </tbody>
            </apex:repeat> 
            </table> 

Any help is appreciated.

1 Answer 1

0

Use rendered attribute.

Your code will be

              <table border="1" cellpadding="6" width="100%" class = "table1">
                    <thead>
                     <tr>
                        <th title="Field #1">test 1</th>
                        <th title="Field #2">test 2</th>
                        <th title="Field #3">test 3</th>
                     </tr>
                    </thead>
                <tbody>
                <apex:repeat value="{!qli}" var="opp">    
                    <tr>
                        <td>
                            <apex:outputText rendered="{!IF(ISNULL(opp.test1) , false , true)}" value="{!opp.test1}" />
                        </td>
                        <td>
                            <apex:outputText rendered="{!IF(ISNULL(opp.test2) , false , true)}" value="{!opp.test2}" />
                        </td>
                        <td>
                            <apex:outputText rendered="{!IF(ISNULL(opp.test3) , false , true)}" value="{!opp.test3}" />
                        </td>
                    </tr>
                </tbody>
            </apex:repeat> 
            </table>
1
  • Would that not just hide the columns rather than the headers? Is there a way to include the headers in that case too. Commented Jul 19, 2020 at 11:52

You must log in to answer this question.

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