Mootools not show colspan td in tr hidden - css

I want to hide information that is in a hidden row as shown no respect colspan. I have:
<table width="100%" cellpadding="0" cellspacing="0" border="1">
<tr>
<td><div id="se">click here!!</div></td>
<td>value 2</td>
<td>value 3</td>
</tr>
<tr><td colspan="3" style="display:none;;">content</td></tr>
and Mootools code
$('se').addEvent('click',function(){
this.getParent('tr').getNext('tr').getElement('td').setStyle('display','block');
});
when I click on "click here!" hidden row is shown, but not colspan.
See example here: http://jsfiddle.net/Xvnhw/1/

this is not to do with MooTools but browser repaint of an element that it has not considered for rendering before.
move to using a CSS based setup, which gets applied after the engine parses the cells and sets correct position.
http://jsfiddle.net/Xvnhw/3/
$('se').addEvent('click',function(){
this.getParent('tr').getNext('tr').getElement('td').removeClass('hide');
});
and css
.hide {
display: none
}
yet another example of why inline element styles are a bad thing.

This has nothing to do with inline styling and everything to do with the display value. The display style should be set to 'table-cell', not 'block'.
Here is the original code, with the only change being change being setting the display value to 'table-cell':
http://jsfiddle.net/L2zz3/
HTML:
<table width="100%" cellpadding="0" cellspacing="0" border="1">
<tr>
<td><div id="se">click here!!</div></td>
<td>value 2</td>
<td>value 3</td>
</tr>
<tr><td colspan="3" style="display:none;;">content</td></tr>
</table>
Mootools code:
$('se').addEvent('click',function(){
this.getParent('tr').getNext('tr').getElement('td').setStyle('display','table-cell');
});
Note how this example has inline styles and still works.
Here is a CSS based setup that sets the display value to 'block':
http://jsfiddle.net/z7hXc/
HTML:
<table width="100%" cellpadding="0" cellspacing="0" border="1">
<tr>
<td><div id="se">click here!!</div></td>
<td>value 2</td>
<td>value 3</td>
</tr>
<tr><td colspan="3" class="hide">content</td></tr>
</table>
Mootools code:
$('se').addEvent('click',function(){
this.getParent('tr').getNext('tr').getElement('td').removeClass('hide').addClass('show');
});
CSS:
.hide {
display:none;
}
.show {
display:block;
}
Notice how this example has the same issues as the original code, but does not use any inline styles. Therefore, this is clearly an issue with 'display':'block', and not due to inline styling.

Related

Equal width columns in long bootstrap table

In the above table to achieve equal width columns I have used <td class="col-md-1"></td>. But only the first few columns are equal width as shown in the image. As this is a long table I would like to scroll horizontally so that the table can maintain the required column width. but this table wouldn't grow. I even tried table{ width:auto !important }
.table {
width: 100%;
max-width: 100%;
margin-bottom: 20px;
}
The above styles get applied for my table from bootstrap
Classes I have used in the table element - <table class="table table-bordered"></table>
Framework: Bootstrap 3
You will want to use this markup:
<div class="table-responsive">
<table class="table">
...
</table>
</div>
Source: Responsive Table Bootstrap
Try to use <th> instead.
Example of table in bootstramp.
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel="stylesheet"/>
<table summary="This table shows how to create responsive tables using Bootstrap's default functionality" class="table table-bordered table-hover">
<caption class="text-center">An example of a responsive table based on Bootstrap:</caption>
<thead>
<tr>
<th>Country</th>
<th>Languages</th>
<th>Population</th>
<th>Median Age</th>
<th>Area (Km²)</th>
</tr>
</thead>
<tbody>
<tr>
<td>Argentina</td>
<td>Spanish (official), English, Italian, German, French</td>
<td>41,803,125</td>
<td>31.3</td>
<td>2,780,387</td>
</tr>
<tr>
<td>Australia</td>
<td>English 79%, native and other languages</td>
<td>23,630,169</td>
<td>37.3</td>
<td>7,739,983</td>
</tr>
<tr>
<td>Greece</td>
<td>Greek 99% (official), English, French</td>
<td>11,128,404</td>
<td>43.2</td>
<td>131,956</td>
</tr>
<tr>
<td>Luxembourg</td>
<td>Luxermbourgish (national) French, German (both administrative)</td>
<td>536,761</td>
<td>39.1</td>
<td>2,586</td>
</tr>
<tr>
<td>Russia</td>
<td>Russian, others</td>
<td>142,467,651</td>
<td>38.4</td>
<td>17,076,310</td>
</tr>
<tr>
<td>Sweden</td>
<td>Swedish, small Sami- and Finnish-speaking minorities</td>
<td>9,631,261</td>
<td>41.1</td>
<td>449,954</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="5" class="text-center">Data retrieved from infoplease and worldometers.</td>
</tr>
</tfoot>
</table>

Nested table issue while printing document

I have a table which I am trying to print. So the basic structure is contains a nested table both containing thead. Once I do a print, the pdf shows overlapping thead.
Please find attached link to reproduce the code. https://www.dropbox.com/s/a0l0s7blh401tg7/table.html
<table>
<thead>
<tr>
<td>heading</td>
</tr>
<tbody>
<tr>
<td>
<table>
<thead>
<tr>
<th>Heading 2</th>
</tr>
</table>
</td>
</tr>
</tbody>
</thead>
</table>
Try the following css (this only helps if you have a very plain thead an only one aswell):
thead { display: table-header-group }
tfoot { display: table-row-group }
tr { page-break-inside: avoid }
Edit:
Regarding your question: The reason why your thead is overlapping is your table markup itself. Right now we have multiple table and thead, and also padding which is causing the overlapping. I did some research and found two different solutions you could use.
Fact 1: Only the lastest thead in your markup will be place on a second page when printed. Therefore you can check and adjust your table like this working example here, print button on the top :
<table>
<!-- thead on first page -->
<thead>
<tr>
<th> ... </th>
</tr>
</thead>
<tbody>
<tr>
<td>
<table>
<!-- thead on first page an all following -->
<thead>
<tr>
<th> ... </th>
</tr>
</thead>
<tbody>
<tr>
<td> ... </td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
Fact 2: In my opinion the only working solution if you want all your thead information on all pages is to move all th in one thead at the top of the table, therefore you will have all informations on every page working example for this solution, print button on the top
Hopefully this helps :)

Bootstrap 3 tables column width control

I have a bootstrap table as follows:
<table class="table table-bordered">
<thead>
<tr>
<th>Col1</th>
<th>Col2</th>
</tr>
</thead>
<tbody>
<tr>
<td>test</td>
<td>test</td>
</tr>
</tbody>
</table>
The two column are equally spaced which is fine but if i drop an <input> element in to one of the columns this column stretches to take up about 3/4 of the overall table.
http://www.bootply.com/115049
My question is why does it do this and how can I control it?
Any help much appreciated.
<table class="table table-bordered">
<thead>
<tr>
<th class="col-md-10">Col1</th>
<th class="col-md-2">Col2</th>
</tr>
</thead>
<tbody>
<tr>
<td>test</td>
<td>test</td>
</tr>
</tbody>
</table>
This is down to the way HTML tables work. By default, table cells will scale according to their contents - any size you give them is used as a guide. So, for instance:
td {
width: 50%;
/*
If this cell is empty, it will take up half of
the table. But if the content needs to, it will
expand to take up more space.
*/
}
You can work around this by setting table-layout: fixed; in your CSS:, e.g.
table.fixed {
table-layout: fixed;
}
This makes tables adhere more strictly to the dimensions you set in CSS, rather than what the content dictates. See https://developer.mozilla.org/en-US/docs/Web/CSS/table-layout for more information.
Once this is done, you can apply the normal Bootstrap grid classes to control the width. Apply them to the cells (td or th) in the first row and they'll repeat all the way down.
Why ? I don't know :)
How to control it ?
You can simply but a width parameter to your td, such as :
<td width=50%><input type="text"></td>
You can do it like this, or using your css file by saying all from this class should take half of the table width.
td {
width: 50%;
}

td with colspan border broken in ie10 quirk mode

ie10 is not showing fine border over colspan.
It is showing well on other browser, but not on IE 10.
I'll post my code below.
HTML CODE:
<table>
<thead>
<tr>
<td rowspan="2">1</td>
<td rowspan="2">2</td>
<td colspan="4">3</td>
<td rowspan="2">4</td>
</tr>
<tr>
<td>5</td>
<td>6</td>
<td colspan="2">7</td>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td colspan="3">4</td>
<td>5</td>
</tr>
</tbody>
</table>
CSS CODE:
table tr td {
border: 1px solid black;
width: 100px;
}
table {
border-collapse:collapse;
}
border under 7 is gone. How can I show it?
here is example on jsfiddle :
http://jsfiddle.net/H4z7Q/
ADD: If some event occurs in ie10, border come back to normal.
You can use table inline style stats. instead of border-collapse:collapse;
<table cellpadding=0 cellspacing=0>
will count as same effect.
but will return and will chrice ur problem
The markup violates the HTML table model, as you can see by checking it with http://validator.w3.org which says, referring to the first row: “Table column 6 established by element td has no cells beginning in it”.
So all bets are off. Modify the table structure so that it conforms, or try to achieve the desired layout using other tools than a layout table.

Different CSS styling for left and right side table data

This is my table:
<table width="100%">
<tr ><td width="35%" height="30" class="left-info" >Criminal Id :</td>
<td width="65%" class="right-info" >CR7887898652</td></tr>
<tr><td height="30" class="right-info" >Full Name :</td><td class="left-info" ></td></tr>
<tr><td height="30" class="right-info" >Date of Birth :</td><td class="left-info" ></td></tr>
</table>
How can I remove these repeating use of class for each table data. As, I've used class="left-info" for left side table data and class="right-info" for right side table data. But, this make the mesh of coding, can anyone suggest me how can I do the same style with minimal code?
You can either switch to a non-table layout (perhaps a DL may suit your needs better), or if you must use a table, consider using the col element, which you can apply a class attribute to.
Example
Using your example above, this is how I would suggest using the col element.
<table id="example">
<col class="label" />
<col class="value" />
<tr>
<td>Criminal Id :</td>
<td>CR7887898652</td>
</tr>
<tr>
<td>Full Name:</td>
<td>Foo Bar</td>
</tr>
<tr>
<td>Date of Birth:</td>
<td>01/14/1983</td>
</tr>
</table>
But, taking into account your example, I think you could accomplish your goal with better semantics and less code if you make use of TH elements and pure CSS:
#example th {
text-align: right;
font-weight: normal;
}
#example td {
text-align: left;
}
...
<table id="example">
<tr>
<th>Criminal Id :</th>
<td>CR7887898652</td>
</tr>
<tr>
<th>Full Name:</th>
<td>Foo Bar</td>
</tr>
<tr>
<th>Date of Birth:</th>
<td>01/14/1983</td>
</tr>
</table>
At this level, it shouldn't really matter if you use a DL or a TABLE as they both are semantically rich elements when used like this. IMHO, I still prefer a DL, but truthfully they can be more difficult to style.

Resources