[Bug] Bad column width when some of the columns are collapsed (hidden) #84
Open
ioleo wants to merge 2 commits intomarkmalek:masterfrom
ioleo:master
Open
[Bug] Bad column width when some of the columns are collapsed (hidden) #84ioleo wants to merge 2 commits intomarkmalek:masterfrom ioleo:master
ioleo wants to merge 2 commits intomarkmalek:masterfrom
ioleo:master
Conversation
I've applied this plugin to a table with:
```css
table td,
table th {
display: none; /* hide all cells */
}
table td.row-label,
table th.row-label,
table td.active,
table th.active {
display: table-cell !important; /* except label and active cells */
}
```
So the markup:
```html
<table>
<thead>
<tr>
<td class="row-label">Employee</td>
<td class="product1 active">product1 sales</td>
<td class="product2">product2 sales</td>
<td class="product3">product3 sales</td>
</tr>
</thead>
<tbody>
<tr>
<td class="row-label">Rob Zombie</td>
<td class="product1 active">5</td>
<td class="product2">3</td>
<td class="product3">7</td>
</tr>
</tbody>
</table>
```
Which will display:
```bash
+------------+----------------+
| Employee | product1 sales |
+------------+----------------+
| Rob Zombie | 5 |
+------------+----------------+
```
Then I added 3 tabs (Product1, Product2, Product3) which with some js ([twitter bootstrap's tab](http://getbootstrap.com/2.3.2/javascript.html#tabs)) add/remove the `active` class from cells.
However, the "padding-right" that was applied to last cell approach does not work, when some cells are hidden. The cell widths are not correct. Eg:
```html
<tr>
<td class="row-label"></td>
<td class="product1 active"></td> <!-- this cell is the last displayed cell, but it does not have the padding -->
<td class="product2"></td> <!-- hidden -->
<td class="product3"></td> <!-- the right padding was added to last cell, but this cell is not displayed -->
</tr>
```
Since dynamicaly adding/removeing padding from visible/hidden cells would be a pain in the ass and could cause more problems, instead I've moved the padding to the div wrapper which solves the problem.
Add fix from previous commit to minified version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've applied this plugin to a table with:
So the markup:
Which will display:
Then I added 3 tabs (Product1, Product2, Product3) which with some js (twitter bootstrap's tab) add/remove the
activeclass from cells (so you can hide "product1" column and show "product2" column instead).However, the "padding-right" that was applied to last cell approach does not work, when some cells are hidden. The cell widths are not correct. Eg:
Since dynamicaly adding/removeing padding from visible/hidden cells would be a pain in the ass and could cause more problems, instead I've moved the padding to the div wrapper which solves the problem.
Ofcourse, this makes the scrollbar appear "outside" the table, but that could be fixed by applying borders to
fht-table-wrapperand removeing outer borders from thetable.