473,395 Members | 1,571 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,395 software developers and data experts.

"rearrangable" columns with CSS?

Hi,
the requirement is to show a table's column at first or second position
depending on css.
my idea is to put the information twice into the table, as first and
third column hiding one of them

I've already tried to set display property on colgroup's col element
but this doesn't work in all browsers (especially ie). So now I'm doing
that on the TD elements.

Here is the code I experiment with:

<html>
<head>
<style type="text/css">
<!--
table { width: 600px; }
td { border: 1px solid #000; }
.col1 { width: 200px; }
.col2 { width: 300px; }
.col3 { width: 200px; }
.col4 { width: 100px; }

.first { display: none; }
.second { }
-->
</style>
</head>
<body>
600px width
<table>
<td>Width assumed</td>
</table>

Version 1:
<table>
<colgroup>
<col class="col1">
<col class="col2">
<col class="col3">
<col class="col4">
</colgroup>
<td class="first">Datum</td>
<td>Bezeichnung</td>
<td class="second">Datum</td>
<td>Link</td>
</table>
Version 2:
<table>
<colgroup>
<col class="col2">
<col class="col3">
<col class="col4">
</colgroup>
<td class="first">Datum</td>
<td>Bezeichnung</td>
<td class="second">Datum</td>
<td>Link</td>
</table>

</body>
</html>

The problem is:
Defining all cols in colgroup results in an incorrect table width
(version 1).

Using version 2 (defining only 3 of the 4 columns) everything seems to
work properly.
Changing the styles to

table { width: 600px; }
td { border: 1px solid #000; }
.col1 { width: 200px; }
.col3 { width: 300px; }
.col2 { width: 200px; }
.col4 { width: 100px; }

.first { }
.second { display: none; }

does what I need (in all tested browsers: ie, mozilla, opera). So I
swap the display property on classes first and second and also swap the
width definition of col2 and clo3.

Now my question: Is that compliant to the css specification. I couldn't
find a hint on how colgroup has to react when TDs are set with
display:none.
Is it really defined that elements set to display:none are handled as
not avialable in general? Has anyone a link to a specification document
describing that? Or is that just a common interpretation of browsers
and could change anytime?

I don't want to use my working solution if its not future safe (css
compliant).

Or: Has anyone another solution to accomplish the column rearrange task
(only using css, no javascript, css compliant, browser independent)?

thanks in advance

May 16 '06 #1
0 1372

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

Similar topics

10
by: VA | last post by:
I got the following function to swap table columns from somewhere on the Internet function swapColumns (table, colIndex1, colIndex2) { if (table && table.rows && table.insertBefore && colIndex1...
2
by: Kevin | last post by:
Hi Al Can someone tell me how to hide colums in a datagrid. I have a one datagrid that is a master and child and I would like to hide specific columns, how do I do this TI Kevin
1
by: Amber | last post by:
The DataGrid allows you to make columns visible or invisible on demand - even edit and other special columns. This article will show you how it is done. Some developers have reported problems...
2
by: CSL | last post by:
I am using the DataGrid in a Windows Application, how can I adjust the widths of each column individually.
13
by: scorpion53061 | last post by:
Very urgent and I am very close but need a little help to get me over the edge........ I need to write these columns to a html file with each row containing these columns (seperated by breaks)....
5
by: Gary Blakely | last post by:
I'm giving this post another try - it can't be too difficult for everyone.... In the program below, the web page has dataGrid1. the only thing that has been done to it at design time is to...
2
by: Dibs | last post by:
Hi all, short question. is there anyway of changing the order of a datatable's columns? cheers, Dibs
1
by: thomasp | last post by:
Will someone tell me why with the following code: 1. The user can not resize the columns 2. The DTG column is not formatted as "dd-MMM-yy HH:mm:ss" 3. The user can modify the data in all...
0
by: bappelsin | last post by:
Hello, I have a problem with the datagridview. I have a view with around 25 different columns. To make life easier for the users I have implemented a popup dialog where the user can select which...
5
by: explode | last post by:
I made a procedure Public Sub Novo(ByVal nova1 As String, ByVal nova2 As String) that creates a new oledbDataAdapter with insert update select and delete commads. I also added that commands can...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.