Hiding Empty Columns In HTML Table - CodeRanch

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
building better world book advertise on coderanch meaningless drivel book review grid thread boost
this forum made possible by our volunteer staff, including ... Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst
Forum:
  • HTML Pages with CSS and JavaScript
Hiding empty columns in HTML table Warren Griscti Ranch Hand Posts: 53 posted 2 years ago
  • Mark post as helpful
  • send pies Number of slices to send: Optional 'thank-you' note: Send
  • Quote
  • Report post to moderator
Hi everyone I need some help or guidance re how to hide empty columns when displaying them in an HTML table. I'm using Node.js and I'm reading data from a mysql database. Is it possible to hide empty columns using javascript when displaying it in the browser. Bear Bibeault Sheriff Posts: 67750 173 I like... Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS posted 2 years ago
  • Mark post as helpful
  • send pies Number of slices to send: Optional 'thank-you' note: Send
  • Quote
  • Report post to moderator
The use of NodeJS and MySQL in the backend seems irrelevant to the question, so let's focus on the display table itself:
  • What constitutes an "empty column"? One where every row has no data? Or is it on a per-row basis? Or... ?
  • How is the HTML table being built from the data? DOM manipulation? React? jQuery? Or....?
  • [Asking smart questions] [About Bear] [Books by Bear]

    Warren Griscti Ranch Hand Posts: 53 posted 2 years ago
    • Mark post as helpful
    • send pies Number of slices to send: Optional 'thank-you' note: Send
    • Quote
    • Report post to moderator
    It's a per row basis because it might be filled or it might not depending on the item. I created the headers and the data being read from mysql is then displayed under its respective header Bear Bibeault Sheriff Posts: 67750 173 I like... Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS posted 2 years ago
    • Mark post as helpful
    • send pies Number of slices to send: Optional 'thank-you' note: Send
    • Quote
    • Report post to moderator
    So what does it mean then to "hide" a column? If the headers show all possible columns, then what's getting hidden?

    [Asking smart questions] [About Bear] [Books by Bear]

    Warren Griscti Ranch Hand Posts: 53 posted 2 years ago
    • Mark post as helpful
    • send pies Number of slices to send: Optional 'thank-you' note: Send
    • Quote
    • Report post to moderator
    The user is presented with a list of all items in the database. The list only displays the id and the name and a show more button is displayed beside each item and when the user presses the show more button of a single item another form showing all fields is displayed. Ex: Id,name, status, …., …. Etc.. as I’m fetching the data by the id from mysql all fields including the empty ones are displayed. I need to hide the empty column to that specific item. Bear Bibeault Sheriff Posts: 67750 173 I like... Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS posted 2 years ago
    • Mark post as helpful
    • send pies Number of slices to send: Optional 'thank-you' note: Send
    • Quote
    • Report post to moderator
    OK, so your "table" for each item really only contains a header row and a single row for the item info, correct? Which begs the question you didn't answer yet: how are you creating the HTML from the item data? It seems a simple matter of not creating the <th> and <td> elements for the columns that have no data, but the specifics depend on what you're using.

    [Asking smart questions] [About Bear] [Books by Bear]

    Your mind is under my control .... your will is now mine .... read this tiny ad Gift giving made easy with the permaculture playing cards https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
    reply reply
      Bookmark Topic Watch Topic
    • New Topic
    Boost this thread! Similar Threads
    • Passing Null Value to Sql database from node.js
    • Optimizing a database
    • Urgent pls Help!!!
    • how to use javascript and scrptlet simultaneously
    • Problem with using a <sql:query> JSTL Tag when retrieving using JOIN
    More...

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