473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to hide column in table

I have a HTML table created using ASP as a web page.

ie.

HEADING1 HEADING2 HEADING3 etc...
data 1 data2 data3 etc
and so on

How can I toggle hide / show the columns individually, anyone ever needed to
do this and have any suggestions.

Regards
Don

Jul 20 '05 #1
9 25781
Don Grover wrote:
I have a HTML table created using ASP as a web page.

ie.

HEADING1 HEADING2 HEADING3 etc...
data 1 data2 data3 etc
and so on

How can I toggle hide / show the columns individually, anyone ever needed
to do this and have any suggestions.

Regards
Don


Hi Don,

Just make some switch or if/then construct to decide if you should output a
column.

You'll get something like:

suppose col1, col2, etc contain 'on' or 'off', depending on the fact if you
want to show them. (You didn't specify how that should work, so you'll have
to cook up that part yourself.)

.... looping here over the rows ....

<tr>
<%
IF (col1='on') THEN
%>
<td>
I have value <%= putithere %>
</td>
<%
END IF
%>
</tr>

...... looping over the rows....
And do that for every column.
If you have a zillion column you better put the logic in an array and make
the code smarter.
Very possible I made some languagemistakes. My ASP got very rusty after I
started using PHP. :-)

Regards,
Erwin Moller
Jul 20 '05 #2
: > HEADING1 HEADING2 HEADING3 etc...
: > data 1 data2 data3 etc
: > and so on
: >
: > How can I toggle hide / show the columns individually, anyone ever
needed
: > to do this and have any suggestions.

Set the style of the collom to be disabled to:
style='display:none;'
And when it may appear again:
style='display:block;'

You can loop over the table and take each 3rd (for example something like):

var RowNumber = 3;
var Elements = document.getElementByID('tableID').getElementByTag ('TD');
for (i=RowNumber-1;i<Elements.length;i=i+RowNumber)
{
Elements[i].style='display:none;'
}

You can built in a switch to test the current display style and change it to
block if it's none also.

Wouter
Jul 20 '05 #3
DJ WIce wrote:
Set the style of the collom to be disabled to:
style='display:none;'
And when it may appear again:
style='display:block;'


"style" refers to object, according to the W3C-DOM Level 2 Style
Specification, and the TD elements initial value for the CSS
"display" property is "table-cell", not "block". Thus it should
be

style.display = "none";

and

style.display = "table-cell";

Else it will only work in non-standards-compliant UAs, if that.
PointedEars

P.S.: Your "From" header is borken.
Jul 20 '05 #4
DU
Thomas 'PointedEars' Lahn wrote:
DJ WIce wrote:
Set the style of the collom to be disabled to:
style='display:none;'
And when it may appear again:
style='display:block;'

"style" refers to object, according to the W3C-DOM Level 2 Style
Specification, and the TD elements initial value for the CSS
"display" property is "table-cell", not "block".


According to the W3C-DOM Level 2 Style Specification, the <col> element
initial value for the CSS "display" property is "table-column", not
"block" and not "table-cell". Now, the subject line was about column in
table...

Thus it should be

style.display = "none";

and

style.display = "table-cell";

....<cough clearing my throat>...
and style.display = "table-column";
Else it will only work in non-standards-compliant UAs, if that.
PointedEars

P.S.: Your "From" header is borken.


and if
style.display = "table-column";
does not work in MSIE 6 for Windows, then you can use
style.display = "block";
so that the code will work for roughly 60% of all web users out there
(that's just a little bit more than a few hundreds of millions of people
on this planet) ... until MSIE 7 for Windows correct all this.

According to
http://www.quirksmode.org/css/contents.html
and
http://www.quirksmode.org/css/display.html#table
display:table-column
is not supported by MSIE 5+ nor Mozilla 1.4.

Nevertheless, one can code to workaround all these difficulties. Here's
a page (local version without brinkster banner ads will validate
perfectly) which will work overall rather well in Mozilla 1.6, Opera
7.50 PR1 build 3494, MSIE 6 for Windows, K-meleon 0.8.2, NS 7.1,
Firebird 0.8+ (build 20040120), MyIE2 vers. 0.9.12 with Gecko 1.5:

http://www10.brinkster.com/doctorunc...nCollapse.html

Modifying the table column structure *and* the table row structure at
the same time will not produce correct layout. But if the user only
tries to modify either only the column structure or only the row
structure, then the layout will be correct. I still need to tweak the
code and tune a few things in the functions to make it more robust. I'm
still working on that file so I don't want to hear nitpicking comments.

I have another demo page where one can show, hide or collapse table
sections like the thead, tbody and tfoot.

Pointed ears, you could have replied in a much more constructive manner.
Again, you focus on little things which can only annoy others or
contribute/lead to clashing <plonk> noises.

DU

Jul 20 '05 #5
DU wrote:

<--snip-->

http://www10.brinkster.com/doctorunc...nCollapse.html
<--snip-->
I'm still working on that file so I don't want to hear nitpicking comments.


No nitpicking - its great so far. Can you post back when its finished?
I noticed two things (probably nitpicky) but want to wait until its
finished.
Also, any chance of you re-uploading the ScrollingTableInMSIE.html file?

I have hunted it for 4 days now and finally found it in the archive.org
site:

<URL:
http://web.archive.org/web/200306082...bleInMSIE.html
/>

Or, do you mind me using it for a demo page with credit given?

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #6
DU
Randy Webb wrote:
DU wrote:

<--snip-->

http://www10.brinkster.com/doctorunc...nCollapse.html
<--snip-->
I'm still working on that file so I don't want to hear nitpicking
comments.

No nitpicking - its great so far. Can you post back when its finished?
I noticed two things (probably nitpicky) but want to wait until its
finished.
Also, any chance of you re-uploading the ScrollingTableInMSIE.html file?


Nope. That was a first draft, first version of the file. Once I was
satisfied with my latest version and could not see how I could further
tune it or improve it, then I *renamed* it and removed
ScrollingTableInMSIE.html

Now, that file is now:

http://www10.brinkster.com/doctorunc...lingTBody.html

and will (should?) work accordingly with NS 7.1, Mozilla 1.3+,
Opera 7.x, MSIE 6, etc.
I have hunted it for 4 days now and finally found it in the archive.org
site:

<URL:
http://web.archive.org/web/200306082...bleInMSIE.html
/>

Or, do you mind me using it for a demo page with credit given?


...with credit given, ok, no problem. Thanks for asking. I appreciate
good ethics in such situation.

DU
--
P.S.: If you want to give more, I'll give you my PayPal address :)
Just kidding. :)
Jul 20 '05 #7
DU
Randy Webb wrote:


Also, any chance of you re-uploading the ScrollingTableInMSIE.html file?

I have hunted it for 4 days now and finally found it in the archive.org
site:

<URL:
http://web.archive.org/web/200306082...bleInMSIE.html
/>

Or, do you mind me using it for a demo page with credit given?


The best thing you can do about scrolling tbody is to ask, demand
browsers to support it without any need of javascript or complex hacks.
Scrolling tbody is quite useful, you know.
I personally filed bug 123296 at Opera's Bug Tracking Database on this.
So if you want to support a permanent, reliable, real cross-browser
solution, then log into opera.general and/or opera.wishlist and/or
opera.page-authoring and demand that Opera supports overflow:auto on
defined tbody length.

See #4 here and the included reference to the W3C HTML 4.01

http://www10.brinkster.com/doctorunc...pera7Bugs.html

"(...) This division [THEAD, TFOOT and TBODY elements] enables user
agents to support scrolling of table bodies independently of the table
head and foot."

HTML 4.01 11.2.3 Row groups: the THEAD, TFOOT, and TBODY elements

I filed the same bug for MSIE 6 in that corresponding section.

DU
Jul 20 '05 #8
: P.S.: Your "From" header is borken.
To avoid "Someone have replied to your message" from some website that
copies this archieve.

Wouter
Jul 20 '05 #9
DJ WIce wrote:
: P.S.: Your "From" header is borken.
To avoid "Someone have replied to your message"
from some website that copies this archieve.


That's your problem. Use filters.

<http://www.interhack.net/pubs/munging-harmful/>
PointedEars
Jul 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Harry | last post by:
I want to provide a drill down facility for the users - the plan is to intially display a table with summary rows containing results of previous selected search criteria. In each summary row you...
6
by: Das | last post by:
Hi everyone, I'm using datagrid control to display the data. I want to hide column to be displayed into the data grid. I'm using the code as given below: Method given below is used to bind the...
4
by: Tim | last post by:
Hi, I am trying to hide the datagrid row header (the left most column that has the 'select' triangle in it which moves with the selected row). It seems to be fairly simple;...
2
by: jeet_sen | last post by:
Hi, I have created a table colelcting data from an XML source. After I built the whole table I ahve given user options to filter out columns from the table. For this I have collected all the...
6
by: Ian Collins | last post by:
I'm having a spot of bother hiding table columns in IE. With FF, setting the column cell's style.display to none (or changing the cell's class name to style that has display: none) completely...
3
by: =?Utf-8?B?Um9iZXJ0IENoYXBtYW4=?= | last post by:
Hi, I have a GridView with a fixed number of columns being returned from a SQL query and each having a simple template: <asp:TemplateField HeaderText="Allocations"> <edititemtemplate>...
13
by: rupak | last post by:
Hi! I have a multiple selection of checkboxes <input type='checkbox' name='coffee' id='col1' value='Address'/> <input type='checkbox' name='coffee' id='col2' value='Name'/> <input...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.