Hide Table Column (but Leave Blank Space Where It Would Have ...

You are viewing limited content. For full access, please sign in. ZoomRatio
  • Fit window
  • Fit width
  • 50%
  • 75%
  • 100%
  • 125%
  • 150%
  • 200%
of Show posts Please wait while this file loads, or download it here. < > Question Subscribe Subscribed Question

Hide Table Column (but leave blank space where it would have appeared)

Version 10 Forms Updated August 7, 2017 Subscribe Subscribed Profile image asked on August 7, 2017

I have a form that has two tables. The first is returning lookup data from a sql table and will have several rows. The second table exists to total the rows from the first table and is fixed to one row. The issue I am having is that the first field in both tables is "Date" (I just copied the first table to create the second one), which obviously will not be totaled. I want to have the total columns in the second table appear directly underneath their corresponding columns in the first table, so I would like to just hide the column name and the input cell but leave the blank space to that the other cells line up properly. If I hide the table column using field rules, it moves everything over and spaces out the columns, which doesn't work for this application.

If anyone can tell me how to hide this table column but pad the row so that the spacing still works, I would really appreciate it. For now I can just hide the column label using javascript, but the input box still appears, which doesn't look professional.

0 0 Post Link Answer Profile image SELECTED ANSWER replied on August 7, 2017 Show version history

I would do this with pure CSS instead of JavaScript since CSS seems to work better when the time comes to store a copy of the form.

You can also target the columns based on name, but you would need to specify the table if you did that since there are technically two "Date" columns.

For example, similar to what Rob said, grab the #q value of the column (not the Table), then you could do the following:

#q100 label, [data-col="q100"] > * { display:none; }

The > * selector will make sure it hides anything under that data column, including the date picker, without hiding the wrapper or changing the size/spacing.

Although it is probably not the way to go in this case since you have multiple tables using the same column names, for future reference you can also use the "data-title" attribute to grab the fields from a specific column:

#q100 label, [data-title="Column Name"] > * { display:none; } 2 0 Post Link Replies Sort by: Most popular
  • Most popular
  • Oldest to newest
  • Newest to oldest
Profile image replied on August 7, 2017

Hi Melanie,

This snippet should do the trick:

$('#q100 label, .date input, .date img').remove();

Directly target the row header via the ID associated with it (so, replace '#q100' with whatever ID is used on your form) . Add the CSS class 'date' (or whatever you want to call it) to the 'Date' field on the table:

That should do it!

~Rob

1 0 Post Link Profile image SELECTED ANSWER replied on August 7, 2017 Show version history

I would do this with pure CSS instead of JavaScript since CSS seems to work better when the time comes to store a copy of the form.

You can also target the columns based on name, but you would need to specify the table if you did that since there are technically two "Date" columns.

For example, similar to what Rob said, grab the #q value of the column (not the Table), then you could do the following:

#q100 label, [data-col="q100"] > * { display:none; }

The > * selector will make sure it hides anything under that data column, including the date picker, without hiding the wrapper or changing the size/spacing.

Although it is probably not the way to go in this case since you have multiple tables using the same column names, for future reference you can also use the "data-title" attribute to grab the fields from a specific column:

#q100 label, [data-title="Column Name"] > * { display:none; } 2 0 Post Link Profile image replied on August 7, 2017

Thank you to both Rob and Jason for this excellent information. I ended up using the CSS only, and it worked perfectly, both for the display of the form and for the saved version inside Laserfiche.

0 0 Post Link You are not allowed to follow up in this post. Sort by: Most popular
  • Newest to oldest
  • Most popular
  • Oldest to newest
View: Expanded
  • Condensed
  • Expanded
Filter: All
  • All
  • Resolved
  • Unresolved

Sign in to reply to this post.

Subscribe Subscribed Details
  • Asked August 7, 2017
  • Updated August 7, 2017
  • 1959 views
Attachments
  • {fileName} {fileName}
    • View
    • Download
    • Go to post
    • Delete
Related Posts Loading ...

Post Editors

OK Cancel

Versions

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