"Dynamic Responsive Tables"
Bootstrap 3.3.0 Snippet by jstirling91

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<style>
td {
white-space: nowrap;
}
</style>
<div class="col-xs-12">
<table id="cand" class="table table-hover table-primary table-bordered colm-freeze" border="0" width="100%">
<thead>
<tr class="info">
<th>No.</th>
<th>Col 1</th>
<th>Col 2</th>
<th id="pscid">Col 3</th>
<th>Col 4</th>
<th>Col 5</th>
<th>Col 6</th>
<th>Col 7</th>
<th>Col 8</th>
<th>Col 9</th>
<th>Col 10</th>
<th>Col 11</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row 1</td>
<td>Row 1, Col 1</td>
<td>Row 1, Col 2</td>
<td><a href="#">Row 4, Col 3</a></td>
<td>Row 1, Col 4</td>
<td>Row 1, Col 5</td>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
.static-col.pis{
padding-bottom: 71px;
}
.pis {
height: 80px;
}
.table-scroll {
overflow-x:auto;
padding-bottom:1px;
}
.table-scroll-static {
overflow-x:auto;
margin-left:7em;
padding-bottom:1px;
}
.scrollable {
margin-right: 50px;
margin-left:50px;
}
.scrollableStat {
margin-right: 50px;
margin-left:10em;
}
.static-col {
position:absolute;
width:7em;
left:0;
top:auto;
word-wrap: break-word;
border-right: 0px none black;
border-top-width:3px; /*only relevant for first row*/
}
.colm-static{
left: 3em;
background: white;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* global window, jQuery*/
/**
* This is a wrapper for a scrollable table that dynamically
* changes depending on weather or not the table has overflow
* or not. The table can be setup to freeze a column once the
* column comes to the left of the screen. The column will
* unfreeze once the column to its right is fully visiable.
*
* To setup the table without freezing a column simply call
* the function DynamicTable on the table you want to apply
* the scrolling using the standard jquery function calling.
* For this the fuction does not take in any parameters.
*
* To setup the table with the freezing column, call in a
* similar manner to the way without the freezing column.
* The only diffrence being you pass an object of the structure
*
* { "freezeColumn" : "columnID" }
*
* columnID: The id of the table id in the first row at the desired
* column
*
* ie. $("#cand").ResponsiveTable({ "freezeColumn" : "col3" });
*
* Authors: Jordan Stirling <jstirling91@gmail.com>
* Dave MacFarlane
*/
(function($) {
"use strict";
var setupScrolling = function(wrapper, rightLink, leftLink) {
var scrolling = false;
var step = 100;
var scrollAmount = 0;
var scrollContent = function(direction, elem) {
$(elem).animate({
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments: