// This value is updated when the document is loaded is inline-table style is not supported
var showStyle = "inline-table";
function expcoll(cell) {
var className = cell.className;
var classType = className.substr(0, 2);
var classID = className.substr(2);
var ctrlClass = ((classType == "ct") ? "cg" : "ct") + classID;
$("." + className).css("display", "none");
$("." + ctrlClass).css("display", showStyle);
}
function cssTest() {
// inline-table doesn't work properly in IE8 (and presumably older versions)
// The data columns get hidden, but the control columns don't appear.
// I suspect this style is not recognised at all, and is ignored when it is seen in the default style sheet
// Just using 'inline' breaks the table in Firefox and Opera -
// the cell widths shrink to the minimum size required to show the contents
// If inline-table is not supported (as with IE) the initial style is 'block', so use 'inline' instead of 'inline-table'
if ($("#testCell").css("display") == "block") showStyle = "inline";
}
<html>
<head>
<style type="text/css">
table td
{
border:solid 1px black;
border-collapse:collapse;
padding: 1px;
}
.cc1 {
width:150px;
background-color:LightBlue;
display:inline-table;
}
.cg1 {
width:150px;
background-color:LightGreen;
display:inline-table;
}
.cg2 {
width:150px;
background-color:LightSkyBlue;
display:inline-table;
}
.cg3 {
width:150px;
background-color:LightSeaGreen;
display:inline-table;
}
.ct1 {
width:10px;
display:none;
background-color:LightGreen;
}
.ct2 {
width:10px;
display:none;
background-color:LightSkyBlue;
}
.ct3 {
width:10px;
display:none;
background-color:LightSeaGreen;
}
</style>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript">
// This value is updated when the document is loaded is inline-table style is not supported
var showStyle = "inline-table";
function expcoll(cell) {
var className = cell.className;
var classType = className.substr(0, 2);
var classID = className.substr(2);
var ctrlClass = ((classType == "ct") ? "cg" : "ct") + classID;
$("." + className).css("display", "none");
$("." + ctrlClass).css("display", showStyle);
}
function cssTest() {
// inline-table doesn't work properly in IE8 (and presumably older versions)
// The data columns get hidden, but the control columns don't appear.
// I suspect this style is not recognised at all, and is ignored when it is seen in the default style sheet
// Just using 'inline' breaks the table in Firefox and Opera -
// the cell widths shrink to the minimum size required to show the contents
// If inline-table is not supported (as with IE) the initial style is 'block', so use 'inline' instead of 'inline-table'
if ($("#testCell").css("display") == "block") showStyle = "inline";
}
</script>
</head>
<body onload="cssTest()">
<table>
<tr>
<td class="cc1">ID</td>
<td class="cg1" ondblclick="expcoll(this)" id="testCell">Group 1</td>
<td class="cg1" ondblclick="expcoll(this)">Group 1</td>
<td class="ct1" ondblclick="expcoll(this)"> </td>
<td class="cg2" ondblclick="expcoll(this)">Group 2</td>
<td class="cg2" ondblclick="expcoll(this)">Group 2</td>
<td class="ct2" ondblclick="expcoll(this)"> </td>
<td class="cg3" ondblclick="expcoll(this)">Group 3</td>
<td class="cg3" ondblclick="expcoll(this)">Group 3</td>
<td class="ct3" ondblclick="expcoll(this)"> </td>
</tr>
<tr>
<td class="cc1">Row 1</td>
<td class="cg1">Row 1</td>
<td class="cg1">Row 1</td>
<td class="ct1"> </td>
<td class="cg2">Row 1</td>
<td class="cg2">Row 1</td>
<td class="ct2"> </td>
<td class="cg3">Row 1</td>
<td class="cg3">Row 1</td>
<td class="ct3"> </td>
</tr>
<tr>
<td class="cc1">Row 2</td>
<td class="cg1">Row 2</td>
<td class="cg1">Row 2</td>
<td class="ct1"> </td>
<td class="cg2">Row 2</td>
<td class="cg2">Row 2</td>
<td class="ct2"> </td>
<td class="cg3">Row 2</td>
<td class="cg3">Row 2</td>
<td class="ct3"> </td>
</tr>
<tr>
<td class="cc1">Row 3</td>
<td class="cg1">Row 3</td>
<td class="cg1">Row 3</td>
<td class="ct1"> </td>
<td class="cg2">Row 3</td>
<td class="cg2">Row 3</td>
<td class="ct2"> </td>
<td class="cg3">Row 3</td>
<td class="cg3">Row 3</td>
<td class="ct3"> </td>
</tr>
</table>
</body>
</html>
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (0)