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.

    Explore Teams Create a free Team
  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 3 years, 11 months ago Modified 3 years, 11 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 237 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 4717 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
  • How to build open source apps in a highly regulated industry
  • Community Products Roadmap Update, July 2024
  • Featured on Meta
  • We spent a sprint addressing your requests — here’s how it went
  • Upcoming initiatives on Stack Overflow and across the Stack Exchange network...
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

  • Why should the Vce be half the value of the supply source?
  • What's the point of Dream Chaser?
  • Con permiso to enter your own house?
  • Seeing edges where there are no edges
  • 6 balls, one is either heavier or lighter, find the odd ball in minimum weighings
  • I want to leave my current job during probation but I don't want to tell the next interviewer I am currently working
  • Why would a plane be allowed to fly to LAX but not Maui?
  • When did the four Gospels receive their printed titles?
  • common.apex.runtime.impl.ExecutionException: Unrecognized base64 character: [
  • Can you always extend an isometry of a subset of a Hilbert Space to the whole space?
  • Can someone explain the Trump immunity ruling?
  • Use of Compile[] to optimize the code to run faster
  • Is there a drawback to using Heart's blood rote repeatedly?
  • Why does Paul's fight with Feyd-Rautha take so long?
  • Staying in USA longer than 3 months
  • Do we know a lower bound or the exact number of 3-way races in France's 2nd round of elections in 2024?
  • How soon should you apply and unapply the sustain pedal after markings?
  • Why does an activated soft fork not invalidate the blockchain?
  • Are there examples of triple entendres in English?
  • What does a letter "R" means in a helipad?
  • exploded pie chart, circumscribing arc, and text labels
  • How to handle a missing author on an ECCV paper submission after the deadline?
  • Word split between two lines is not found in man pages search
  • Who originated the idea that the purpose of government is to protect its citizens?
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