How To Hide Empty Columns In HTML Table

    1. Home
    2. Questions
    3. Tags
    4. Users
    5. Jobs
    6. Companies
    7. Unanswered
  1. Teams

    Ask questions, find answers and collaborate at work with Stack Overflow for Teams.

    Try Teams for free Explore Teams
  2. Teams
  3. Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams How to hide empty columns in HTML Table Ask Question Asked 4 years, 4 months ago Modified 4 years, 4 months ago Viewed 1k times -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.

Share Improve this question Follow asked Jul 17, 2020 at 15:26 Shaan Khokhar's user avatar Shaan KhokharShaan Khokhar 231 silver badge7 bronze badges Add a comment |

1 Answer 1

Sorted by: Reset to default Highest score (default) Date modified (newest first) Date created (oldest first) 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> Share Improve this answer Follow answered Jul 17, 2020 at 15:46 Noor A Shuvo's user avatar Noor A ShuvoNoor A Shuvo 4818 silver badges23 bronze badges 1
  • Would that not just hide the columns rather than the headers? Is there a way to include the headers in that case too. – Shaan Khokhar Commented Jul 19, 2020 at 11:52
Add a comment |

You must log in to answer this question.

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

  • The Overflow Blog
  • We'll Be In Touch - A New Podcast From Stack Overflow!
  • The app that fights for your data privacy rights
  • Featured on Meta
  • More network sites to see advertising test
  • We’re (finally!) going to the cloud!
3 How do we dynamically add columns in a datatable 1 Trying to create a table (edittable or not) with visualforce from fields that exist within account 0 Hide Columns in a VF Table if variable is chosen 1 SelectRadio in HTML Table forces linebreak 3 hide a table when rendering a PDF 0 Action support on html table 4 Hide HTML table rows if outputField is null or 0 0 Display html table from date wrapper 0 Hide <td> in visualforce page if td is empty

Hot Network Questions

  • Can a storage device completely erase itself while performing the erase?
  • Asymptotic Expansion of a Recurrence Relation Involving a Square Root
  • Looking for a letter from H. P. Lovecraft to R. E. Howard
  • Do rediscoveries justify publication?
  • Darlington-driven PNP vs. MOSFET
  • Chain skipping when pedaling hard
  • Is partial correctness decidable?
  • Power series of the reciprocal of f defined as a power series
  • Dominant chord -- is its definition super flexible in blues or did I spot a mistake?
  • Why「记」for shop names?
  • How does the Warlock's invocation Gaze of Two Minds interact with a creature with the Invisible Condition?
  • Brushing pastries with jam
  • Is Exception caught in the Service class a matter of preference?
  • Can I pretend that Spearman's = Pearson's correlation coefficients for meta analysis?
  • How to protect against fake gold bars?
  • What are the ethical considerations regarding mandatory class participation?
  • Why does 写真に収めとこ mean take a picture? And what is the purpose of とこ in this case?
  • Does Windows 11 PIN Behavior Break Password Security Conventions?
  • Lowest processable signal level after FFT with given noise level
  • How to utilize zener diode specs
  • The Talking Dog's Treats
  • Suggestion for catching a flight with short layover in Amsterdam
  • Do switches try to keep track of Ethernet group membership?
  • Misplaced \noalign while using tabularray
more hot questions Question feed Subscribe to RSS Question feed

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

lang-xml

Từ khóa » Html Table Hide Column If Empty