├── img
└── demonstration.png
├── RECOMMENDATIONS.md
├── bower.json
├── package.json
├── LICENSE
├── docs
├── narrow-jumbotron.css
├── dist
│ └── js
│ │ └── freeze-table.js
└── index.html
├── README.md
├── dist
└── js
│ ├── freeze-table.min.js
│ └── freeze-table.js
└── src
└── js
└── freeze-table.js
/img/demonstration.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yidas/jquery-freeze-table/HEAD/img/demonstration.png
--------------------------------------------------------------------------------
/RECOMMENDATIONS.md:
--------------------------------------------------------------------------------
1 | RECOMMENDATIONS
2 | ===============
3 |
4 | ### Artsiom Chorny
5 |
6 | Артём Чёрный \<1203994@gmail.com\> *Dec 14, 2018*
7 |
8 | > Hi Nick,
9 | >
10 | > I faced a need to apply freezing for header and column of table at the same time during development. So, I've found your library (jquery-freeze-table) after few days of searching. It's completely that I wanted to get.
11 | >
12 | > Therefore I'd like to Thank you and show respect. Because I've finally got happiness. It's due to your merit and great work. You rock :)
13 | >
14 | > **Yours respectfully,**
15 | > **Artsiom Chorny**
16 |
--------------------------------------------------------------------------------
/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jquery-freeze-table",
3 | "description": "RWD Table with freezing head and columns for jQuery",
4 | "version": "1.1.0",
5 | "keywords": [
6 | "RWD",
7 | "responsive",
8 | "tables",
9 | "freeze",
10 | "fixed",
11 | "row",
12 | "column",
13 | "head",
14 | "scorll bar"
15 | ],
16 | "homepage": "https://github.com/yidas/jquery-freeze-table",
17 | "authors": [
18 | "Nick Tsai "
19 | ],
20 | "repository": {
21 | "type": "git",
22 | "url": "git://github.com/yidas/jquery-freeze-table.git"
23 | },
24 | "license": "MIT",
25 | "main": [
26 | "dist/js/freeze-table.js"
27 | ],
28 | "ignore": [
29 | ".*",
30 | "docs"
31 | ],
32 | "dependencies": {
33 | "jquery": ">=1.10.1"
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jquery-freeze-table",
3 | "description": "RWD Table with freezing head and columns for jQuery",
4 | "version": "1.3.0",
5 | "keywords": [
6 | "RWD",
7 | "responsive",
8 | "tables",
9 | "freeze",
10 | "fixed",
11 | "row",
12 | "column",
13 | "head",
14 | "scorll bar"
15 | ],
16 | "homepage": "https://github.com/yidas/jquery-freeze-table",
17 | "authors": [
18 | "Nick Tsai "
19 | ],
20 | "repository": {
21 | "type": "git",
22 | "url": "https://github.com/yidas/jquery-freeze-table.git"
23 | },
24 | "bugs": {
25 | "url": "https://github.com/yidas/jquery-freeze-table/issues"
26 | },
27 | "license": {
28 | "type": "MIT",
29 | "url": "https://github.com/yidas/js-freeze-table/blob/master/LICENSE"
30 | },
31 | "main": "dist/js/freeze-table.js"
32 | }
33 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Nick Tsai
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/docs/narrow-jumbotron.css:
--------------------------------------------------------------------------------
1 | /* Space out content a bit */
2 | body {
3 | padding-top: 1.5rem;
4 | padding-bottom: 1.5rem;
5 | }
6 |
7 | /* Everything but the jumbotron gets side spacing for mobile first views */
8 | .header,
9 | .marketing,
10 | .footer {
11 | padding-right: 1rem;
12 | padding-left: 1rem;
13 | }
14 |
15 | /* Custom page header */
16 | .header {
17 | padding-bottom: 1rem;
18 | border-bottom: .05rem solid #e5e5e5;
19 | }
20 | /* Make the masthead heading the same height as the navigation */
21 | .header h3 {
22 | margin-top: 0;
23 | margin-bottom: 0;
24 | line-height: 3rem;
25 | }
26 |
27 | /* Custom page footer */
28 | .footer {
29 | padding-top: 1.5rem;
30 | color: #777;
31 | border-top: .05rem solid #e5e5e5;
32 | }
33 |
34 | /* Customize container */
35 | @media (min-width: 48em) {
36 | .container {
37 | max-width: 46rem;
38 | }
39 | }
40 | .container-narrow > hr {
41 | margin: 2rem 0;
42 | }
43 |
44 | /* Main marketing message and sign up button */
45 | .jumbotron {
46 | text-align: center;
47 | border-bottom: .05rem solid #e5e5e5;
48 | }
49 | .jumbotron .btn {
50 | padding: .75rem 1.5rem;
51 | font-size: 1.5rem;
52 | }
53 |
54 | /* Supporting marketing content */
55 | .marketing {
56 | margin: 3rem 0;
57 | }
58 | .marketing p + h4 {
59 | margin-top: 1.5rem;
60 | }
61 |
62 | /* Responsive: Portrait tablets and up */
63 | @media screen and (min-width: 48em) {
64 | /* Remove the padding we set earlier */
65 | .header,
66 | .marketing,
67 | .footer {
68 | padding-right: 0;
69 | padding-left: 0;
70 | }
71 | /* Space out the masthead */
72 | .header {
73 | margin-bottom: 2rem;
74 | }
75 | /* Remove the bottom border on the jumbotron for visual effect */
76 | .jumbotron {
77 | border-bottom: 0;
78 | }
79 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
RWD Freeze Table
6 |
7 |
8 |
9 | [](https://www.npmjs.com/package/jquery-freeze-table)
10 | [](https://github.com/yidas/jquery-freeze-table/blob/master/LICENSE)
11 |
12 | RWD Table with freezing head and columns for jQuery
13 |
14 | FEATURES
15 | --------
16 |
17 | - *Freeze the **head rows and columns** for large table with RWD*
18 |
19 | - ***Optional features** such as Freeze Scroll Bar*
20 |
21 | - ***Namespace support** for multiple tables*
22 |
23 | ---
24 |
25 | OUTLINE
26 | -------
27 |
28 | - [Demonstration](#demonstration)
29 | - [Requirements](#requirements)
30 | - [Installation](#installation)
31 | - [Bower Installation](#bower-installation)
32 | - [Assets include](#assets-include)
33 | - [Initialize via JavaScript](#initialize-via-javascript)
34 | - [Options](#options)
35 | - [Implementation](#implementation)
36 | - [Resize](#resize)
37 | - [Update for Dynamic Content](#update-for-dynamic-content)
38 | - [Namespace](#namespace)
39 | - [Table Opacity](#table-opacity)
40 | - [API Usage](#api-usage)
41 |
42 | ---
43 |
44 | DEMONSTRATION
45 | -------------
46 |
47 | [https://yidas.github.io/jquery-freeze-table/](https://yidas.github.io/jquery-freeze-table/)
48 |
49 |
50 |
51 | ---
52 |
53 | REQUIREMENTS
54 | ------------
55 | This library requires the following:
56 |
57 | - jQuery 1.11.0+ | 2.0+ | 3.0+
58 |
59 | ---
60 |
61 | INSTALLATION
62 | ------------
63 |
64 | ### Bower Installation
65 |
66 | ```
67 | bower install jquery-freeze-table
68 | ```
69 |
70 | > You could also download by [NPM](https://www.npmjs.com/package/jquery-freeze-table) or directly copy [`dist`](https://github.com/yidas/jquery-freeze-table/tree/master/dist) assets.
71 |
72 | ### Assets include
73 |
74 | Add JavaScript file either to the ``, or to the bottom of ``
75 |
76 | ```html
77 |
78 | ```
79 |
80 | ### Markup
81 |
82 | Add the classes `.table` to the tables as usual when using Bootstrap, then wrap them with a identity such as `.freeze-table`
83 |
84 | ```html
85 |
86 |
87 |
88 | | ... |
89 |
90 |
91 | ... |
92 |
93 |
94 |
95 | ```
96 |
97 | ### Initialize via JavaScript
98 |
99 | You can initialize Freeze Table by jQuery extension call:
100 |
101 | ```html
102 |
107 | ```
108 |
109 | Or initialize an element by newing object from Freeze Table class:
110 |
111 | ```html
112 |
117 | ```
118 |
119 | > The parameter `{}` is [options](#options) configuration
120 |
121 |
122 |
123 | ### Options
124 |
125 | Options could be passed via JavaScript with object.
126 |
127 | |Name |Type |Default |Description|
128 | |:-- |:-- |:-- |:-- |
129 | |freezeHead |boolean |true |Enable to freeze ``|
130 | |freezeColumn |boolean |true |Enable to freeze column(s)|
131 | |freezeColumnHead|boolean |true |Enable to freeze column(s) head (Entire column)|
132 | |scrollBar |boolean |false |Enable fixed scrollBar for X axis|
133 | |fixedNavbar |string\|jQuery\|Element |'.navbar-fixed-top'|Fixed navbar deviation consideration. **Example**: `'#navbar'`|
134 | |scrollable |boolean |false |Enable Scrollable mode for inner scroll Y axis|
135 | |fastMode |boolean |false |Enable Fast mode for better performance but less accuracy|
136 | |namespace |string |'freeze-table' |Table namespace for unbind|
137 | |container |string\|jQuery\|Element |false|Specify a document role element that contains the table. Default container is `window`. This option is particularly useful in that it allows you to position the table in the flow of the document near the triggering element - which will make the freeze table support in containers such as Bootstrap Modal. **Example**: `'#myModal'`|
138 | |columnNum |integer |1 |The number of column(s) for freeze|
139 | |columnKeep |boolean |false |Freeze column(s) will always be displayed to support interactive table|
140 | |columnBorderWidth|interger|1 |The addon border width for freeze column(s)|
141 | |columnWrapStyles |object |null |Customized CSS styles for freeze column(s) wrap. `{'style': 'value'}`|
142 | |headWrapStyles |object |null |Customized CSS styles for freeze head(s) wrap. `{'style': 'value'}`|
143 | |columnHeadWrapStyles|object|null |Customized CSS styles for freeze column-head wrap. `{'style': 'value'}`|
144 | |callback |function|null |Plugin after initialization callback function|
145 | |shadow |boolean |false |Enable default `box-shadow` UI|
146 | |backgroundColor |string\|boolean |'white' |Default table background color for Boostrap transparent UI. `white`, `#FFFFFF`, `rgb(255,255,255,1)`, or `false` to skip.|
147 |
148 | ---
149 |
150 | IMPLEMENTATION
151 | --------------
152 |
153 | ### Resize
154 |
155 | There is an resize method which you can call when the page container has changed but not triggering window resize. The method will resize Freeze Table to ensure the size fits.
156 |
157 | ```javascript
158 | $('.freeze-table').freezeTable('resize');
159 | ```
160 |
161 | Or using API usage to update:
162 |
163 | ```javascript
164 | var freezeTable = new FreezeTable('.freeze-table', {'namespace': 'first-table'});
165 | // Resize Freeze Table while the page container is distorted
166 | $('.sider-bar-switch').click(function () {
167 | freezeTable.resize();
168 | });
169 | ```
170 |
171 | > Trigger `$(window).resize()` will also work for every Freeze Table.
172 |
173 | ### Update for Dynamic Content
174 |
175 | There is an update method which you can call when the table or it's contents has changed. The method will reinitialze Freeze Table to ensure that everything is alright with the same options.
176 |
177 | ```javascript
178 | $('.freeze-table').freezeTable('update');
179 | ```
180 |
181 | Or using API usage to update:
182 |
183 | ```javascript
184 | var freezeTable = new FreezeTable('.freeze-table', {'namespace': 'first-table'});
185 | // Update Freeze Table while the original table is distorted
186 | $('.freeze-table > table .btn-expand').click(function () {
187 | freezeTable.update();
188 | });
189 | ```
190 |
191 | ### Namespace
192 |
193 | To destroy or update Freeze Tables, it's recommended to define namespaces to each Freeze Table so that they could able to destroy itself.
194 |
195 | Namespace has default value which Freeze Tables with same namespace would affect each other.
196 |
197 | ```javascript
198 | $("#table-first").freezeTable({
199 | 'namespace': 'table-first',
200 | });
201 | ```
202 |
203 | ### Table Opacity
204 |
205 | Bootstrap sets table's `background-color` as `transparent` by default, so that you may need to define `backgroundColor` option for your own page:
206 |
207 | ```javascript
208 | $(".table-black").freezeTable({
209 | 'backgroundColor': 'rgb(0,0,0,1)',
210 | });
211 | ```
212 |
213 | ---
214 |
215 | API USAGE
216 | ---------
217 |
218 | ### resize()
219 |
220 | Resize trigger for current same namespace
221 |
222 | *See [Resize](#resize)*
223 |
224 | ### update()
225 |
226 | Update for Dynamic Content
227 |
228 | *See [Update for Dynamic Content](#update-for-dynamic-content)*
229 |
230 | ### destroy()
231 |
232 | Destroy Freeze Table by same namespace
233 |
234 | ### unbind()
235 |
236 | Unbind all events by same namespace
237 |
238 | ---
239 |
240 | Finally, I hope that you guys will like this library and enjoy it, and I want to thanks for all your [RECOMMENDATIONS](https://github.com/yidas/jquery-freeze-table/blob/master/RECOMMENDATIONS.md).
241 |
242 | Other kit reference:
243 |
244 | - [jquery-reflow-table](https://github.com/yidas/jquery-reflow-table) - RWD reflow table switch for mobile UI/UX by collapsing columns
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
--------------------------------------------------------------------------------
/dist/js/freeze-table.min.js:
--------------------------------------------------------------------------------
1 | /**
2 | * RWD Table with freezing head and columns for jQuery
3 | *
4 | * @author Nick Tsai
5 | * @version 1.3.0
6 | * @see https://github.com/yidas/jquery-freeze-table
7 | */
8 | !function(i,e){"use strict";var t=function(t,s){return this.$tableWrapper=i(t).first(),this.options=s||{},this.namespace=this.options.namespace||"freeze-table",this.callback,this.scrollBarHeight,this.shadow,this.fastMode,this.backgroundColor,this.scrollable,this.$table=this.$tableWrapper.children("table"),this.$container=void 0!==this.options.container&&this.options.container&&i(this.options.container).length?i(this.options.container):i(e),this.$headTableWrap,this.$columnTableWrap,this.$columnHeadTableWrap,this.$scrollBarWrap,this.fixedNavbarHeight,this.isWindowScrollX=!1,this.headWrapClass="clone-head-table-wrap",this.columnWrapClass="clone-column-table-wrap",this.columnHeadWrapClass="clone-column-head-table-wrap",this.scrollBarWrapClass="clone-scroll-bar-wrap",this.init(),this};t.prototype.init=function(){if(!this.$table.length)throw"The element must contain a table dom";if("update"===this.options)this.destroy(),this.options=this.$tableWrapper.data("freeze-table-data");else{if("resize"===this.options)return this.options=this.$tableWrapper.data("freeze-table-data"),this.namespace=this.options.namespace||this.namespace,void this.resize();this.$tableWrapper.data("freeze-table-data",this.options)}var t=this.options,s=void 0===t.freezeHead||t.freezeHead,a=void 0===t.freezeColumn||t.freezeColumn,l=void 0===t.freezeColumnHead||t.freezeColumnHead,o=void 0!==t.scrollBar&&t.scrollBar,r=t.fixedNavbar||".navbar-fixed-top",n=t.callback||null;this.namespace=this.options.namespace||this.namespace,this.scrollBarHeight=i.isNumeric(t.scrollBarHeight)?t.scrollBarHeight:e.innerWidth-document.documentElement.clientWidth,this.shadow=void 0!==t.shadow&&t.shadow,this.fastMode=void 0!==t.fastMode&&t.fastMode,this.backgroundColor=void 0!==t.backgroundColor?t.backgroundColor:"white",this.scrollable=void 0!==t.scrollable&&t.scrollable,this.fixedNavbarHeight=r&&i(r).outerHeight()||0,this.isInit()&&this.destroy(),this.scrollable||this.$tableWrapper.css("height","100%").css("min-height","100%").css("max-height","100%"),s&&this.buildHeadTable(),a&&(this.buildColumnTable(),this.$tableWrapper.css("overflow-x","scroll")),l&&s&&a&&this.buildColumnHeadTable(),o&&this.buildScrollBar();var h=function(){this.$container.scrollLeft()>0?(this.isWindowScrollX=!0,this.$headTableWrap&&this.$headTableWrap.css("visibility","hidden"),this.$columnTableWrap&&this.$columnTableWrap.css("visibility","hidden"),this.$columnHeadTableWrap&&this.$columnHeadTableWrap.css("visibility","hidden"),this.$scrollBarWrap&&this.$scrollBarWrap.css("visibility","hidden")):this.isWindowScrollX=!1}.bind(this);this.$container.on("scroll."+this.namespace,function(){h()}),this.resize(),"function"==typeof n&&n()},t.prototype.buildHeadTable=function(){var t=this,s=this.clone(this.$table);if(this.fastMode)s=this.simplifyHead(s);var a=this.options.headWrapStyles||null;if(this.$headTableWrap=i('').append(s).css("position","fixed").css("overflow","hidden").css("visibility","hidden").css("top",0+this.fixedNavbarHeight).css("z-index",2),this.shadow&&this.$headTableWrap.css("box-shadow","0px 6px 10px -5px rgba(159, 159, 160, 0.8)"),a&&"object"==typeof a&&i.each(a,function(i,e){t.$headTableWrap.css(i,e)}),this.$tableWrapper.append(this.$headTableWrap),this.$tableWrapper.on("scroll."+this.namespace,function(){t.$headTableWrap.scrollLeft(i(this).scrollLeft())}),this.scrollable){var l=function(i,e){var t=e.$tableWrapper.offset().top;e.$tableWrapper.scrollTop()>0&&t>e.fixedNavbarHeight?(e.$headTableWrap.offset({top:t}),e.$headTableWrap.css("visibility","visible")):e.$headTableWrap.css("visibility","hidden")};this.$tableWrapper.on("scroll."+this.namespace,function(){l(0,t)}),this.$container.on("scroll."+this.namespace,function(){l(0,t)})}else i.isWindow(t.$container.get(0))?this.$container.on("scroll."+this.namespace,function(){var i=t.$container.scrollTop()+t.fixedNavbarHeight,e=t.$table.offset().top-1;e-1<=i&&e+t.$table.outerHeight()-1>=i?t.$headTableWrap.css("visibility","visible"):t.$headTableWrap.css("visibility","hidden")}):this.$container.on("scroll."+this.namespace,function(){var s=i(e).scrollTop(),a=t.$table.offset().top-1;a<=s&&a+t.$table.outerHeight()-1>=s?(t.$headTableWrap.offset({top:s}),t.$headTableWrap.css("visibility","visible")):t.$headTableWrap.css("visibility","hidden")});this.$container.on("resize."+this.namespace,function(){var i=t.scrollable?t.$tableWrapper.width()-t.scrollBarHeight:t.$tableWrapper.width();i=i>0?i:t.$tableWrapper.width(),t.$headTableWrap.css("width",i),t.$headTableWrap.css("height",t.$table.find("thead").outerHeight())})},t.prototype.buildColumnTable=function(){var e=this,t=this.options.columnWrapStyles||null,s=this.options.columnNum||1,a=void 0!==this.options.columnKeep&&this.options.columnKeep,l=this.shadow?0:1,o=void 0!==this.options.columnBorderWidth?this.options.columnBorderWidth:l,r=this.clone(this.$table);if(this.$columnTableWrap=i('').append(r).css("position","fixed").css("overflow","hidden").css("visibility","hidden").css("z-index",1),this.shadow&&this.$columnTableWrap.css("box-shadow","6px 0px 10px -5px rgba(159, 159, 160, 0.8)"),t&&"object"==typeof t&&i.each(t,function(i,t){e.$columnTableWrap.css(i,t)}),this.scrollable){var n=this.$tableWrapper.height()-this.scrollBarHeight;n=n>0?n:this.$tableWrapper.height(),this.$columnTableWrap.height(n)}this.$tableWrapper.append(this.$columnTableWrap);var h=function(){e.$columnTableWrap.offset({top:e.$tableWrapper.offset().top})};a?this.$columnTableWrap.css("visibility","visible"):e.scrollable?this.$tableWrapper.on("scroll."+this.namespace,function(){i(this).scrollLeft()>0?(e.$columnTableWrap.scrollTop(e.$tableWrapper.scrollTop()),e.$columnTableWrap.css("visibility","visible")):e.$columnTableWrap.css("visibility","hidden")}):this.$tableWrapper.on("scroll."+this.namespace,function(){e.isWindowScrollX||(i(this).scrollLeft()>0?e.$columnTableWrap.css("visibility","visible"):e.$columnTableWrap.css("visibility","hidden"))}),this.$container.on("resize."+this.namespace,function(){r.width(e.$table.width());for(var i=0+o,t=1;t<=s;t++){var a=e.$table.find("th:nth-child("+t+")").outerWidth();i+=a>0?a:e.$table.find("td:nth-child("+t+")").outerWidth()}e.$columnTableWrap.width(i),h()}),this.$container.on("scroll."+this.namespace,function(){h()})},t.prototype.buildColumnHeadTable=function(){var t=this;this.$columnHeadTableWrap=this.clone(this.$headTableWrap),this.fastMode&&(this.$columnHeadTableWrap=this.simplifyHead(this.$columnHeadTableWrap));var s=this.options.columnHeadWrapStyles||null;if(this.$columnHeadTableWrap.removeClass(this.namespace).addClass(this.columnHeadWrapClass).css("z-index",3),this.shadow&&this.$columnHeadTableWrap.css("box-shadow","none"),s&&"object"==typeof s&&i.each(s,function(i,e){this.$columnHeadTableWrap.css(i,e)}),this.$tableWrapper.append(this.$columnHeadTableWrap),this.scrollable){var a=function(){var i=t.$tableWrapper.offset().top;t.$tableWrapper.scrollTop()>0&&i>t.fixedNavbarHeight?(t.$columnHeadTableWrap.offset({top:i}),t.$columnHeadTableWrap.css("visibility","visible")):t.$columnHeadTableWrap.css("visibility","hidden")};i(this.$tableWrapper).on("scroll."+this.namespace,function(){a()})}else if(i.isWindow(this.$container.get(0)))a=function(){var i=t.$container.scrollTop()+t.fixedNavbarHeight,e=t.$table.offset().top-1;e-1<=i&&e+t.$table.outerHeight()-1>=i&&t.$tableWrapper.scrollLeft()>0?t.$columnHeadTableWrap.css("visibility","visible"):t.$columnHeadTableWrap.css("visibility","hidden")};else a=function(){var s=i(e).scrollTop(),a=t.$table.offset().top-1;a<=s&&a+t.$table.outerHeight()-1>=s&&t.$tableWrapper.scrollLeft()>0?(t.$columnHeadTableWrap.offset({top:s}),t.$columnHeadTableWrap.css("visibility","visible")):t.$columnHeadTableWrap.css("visibility","hidden")};this.$container.on("scroll."+this.namespace,function(){a()}),this.$tableWrapper.on("scroll."+this.namespace,function(){t.isWindowScrollX||a()}),this.$container.on("resize."+this.namespace,function(){t.$columnHeadTableWrap.find("> table").css("width",t.$table.width()),t.$columnHeadTableWrap.css("width",t.$columnTableWrap.width()),t.$columnHeadTableWrap.css("height",t.$table.find("thead").outerHeight())})},t.prototype.buildScrollBar=function(){var e=this,t=this.$table.find("thead").outerHeight(),s=i('').css("width",this.$table.width()).css("height",1);this.$scrollBarWrap=i('').css("position","fixed").css("overflow-x","scroll").css("visibility","hidden").css("bottom",0).css("z-index",2).css("width",this.$tableWrapper.width()).css("height",this.scrollBarHeight),this.$scrollBarWrap.append(s),this.$tableWrapper.append(this.$scrollBarWrap),this.$scrollBarWrap.on("scroll."+this.namespace,function(){e.$tableWrapper.scrollLeft(i(this).scrollLeft())}),this.$tableWrapper.on("scroll."+this.namespace,function(){e.$scrollBarWrap.scrollLeft(i(this).scrollLeft())}),this.$container.on("scroll."+this.namespace,function(){var i=e.$container.scrollTop()+e.$container.height()-t+e.fixedNavbarHeight;e.$table.offset().top-1<=i&&e.$table.offset().top+e.$table.outerHeight()-1>=i?e.$scrollBarWrap.css("visibility","visible"):e.$scrollBarWrap.css("visibility","hidden")}),this.$container.on("resize."+this.namespace,function(){s.css("width",e.$table.width()),e.$scrollBarWrap.css("width",e.$tableWrapper.width())})},t.prototype.clone=function(e){var t=i(e).clone().removeAttr("id");return this.backgroundColor&&t.css("background-color",this.backgroundColor),t},t.prototype.simplifyHead=function(e){var t=this,s=i(e);return s.find("> tr, > tbody > tr, tfoot > tr").not(":first").remove(),i.each(s.find("> thead > tr:nth-child(1) >"),function(e,s){var a=t.$table.find("> thead > tr:nth-child(1) > :nth-child("+parseInt(e+1)+")").outerWidth();i(this).css("width",a)}),s},t.prototype.isInit=function(){return!!this.$tableWrapper.find("."+this.headWrapClass).length||(!!this.$tableWrapper.find("."+this.columnWrapClass).length||(!!this.$tableWrapper.find("."+this.columnHeadWrapClass).length||!!this.$tableWrapper.find("."+this.scrollBarWrapClass).length))},t.prototype.unbind=function(){this.$container.off("resize."+this.namespace),this.$container.off("scroll."+this.namespace),this.$tableWrapper.off("scroll."+this.namespace)},t.prototype.destroy=function(){this.unbind(),this.$tableWrapper.find("."+this.headWrapClass).remove(),this.$tableWrapper.find("."+this.columnWrapClass).remove(),this.$tableWrapper.find("."+this.columnHeadWrapClass).remove(),this.$tableWrapper.find("."+this.scrollBarWrapClass).remove()},t.prototype.resize=function(){return this.$container.trigger("resize."+this.namespace),this.$container.trigger("scroll."+this.namespace),this.$tableWrapper.trigger("scroll."+this.namespace),!0},t.prototype.update=function(){return this.options="update",this.init(),this},e.FreezeTable=t,i.fn.freezeTable=function(i){if(1===this.length)return new t(this,i);if(this.length>1){var e=[];return this.each(function(){e.push(new t(this,i))}),e}return!1}}(jQuery,window);
--------------------------------------------------------------------------------
/dist/js/freeze-table.js:
--------------------------------------------------------------------------------
1 | /**
2 | * RWD Table with freezing head and columns for jQuery
3 | *
4 | * @author Nick Tsai
5 | * @version 1.3.0
6 | * @see https://github.com/yidas/jquery-freeze-table
7 | */
8 | (function ($, window) {
9 |
10 | 'use strict';
11 |
12 | /**
13 | * Main object
14 | *
15 | * @param {element} element
16 | * @param {object} options
17 | */
18 | var FreezeTable = function(element, options) {
19 |
20 | // Target element initialization
21 | this.$tableWrapper = $(element).first();
22 |
23 | // Options
24 | this.options = options || {};
25 | this.namespace = this.options.namespace || 'freeze-table';
26 | this.callback;
27 | this.scrollBarHeight;
28 | this.shadow;
29 | this.fastMode;
30 | this.backgroundColor;
31 | this.scrollable;
32 |
33 | // Caches
34 | this.$table = this.$tableWrapper.children("table");
35 | this.$container = ((typeof this.options.container !== 'undefined') && this.options.container && $(this.options.container).length) ? $(this.options.container) : $(window);
36 | this.$headTableWrap;
37 | this.$columnTableWrap;
38 | this.$columnHeadTableWrap;
39 | this.$scrollBarWrap;
40 | this.fixedNavbarHeight;
41 | this.isWindowScrollX = false;
42 |
43 | // Static class names for clone wraps
44 | this.headWrapClass = 'clone-head-table-wrap';
45 | this.columnWrapClass = 'clone-column-table-wrap';
46 | this.columnHeadWrapClass = 'clone-column-head-table-wrap';
47 | this.scrollBarWrapClass = 'clone-scroll-bar-wrap';
48 |
49 | this.init();
50 |
51 | return this;
52 | }
53 |
54 | /**
55 | * Initialization
56 | */
57 | FreezeTable.prototype.init = function() {
58 |
59 | // Element check
60 | if (!this.$table.length) {
61 | throw "The element must contain a table dom";
62 | }
63 |
64 | /**
65 | * Update Mode
66 | */
67 | if (this.options==='update') {
68 |
69 | this.destroy();
70 | this.options = this.$tableWrapper.data('freeze-table-data');
71 | }
72 | else if (this.options==='resize') {
73 |
74 | this.options = this.$tableWrapper.data('freeze-table-data');
75 | // Get selected FreezeTable's namespace
76 | this.namespace = this.options.namespace || this.namespace;
77 | this.resize();
78 | // Skip init for better performance usage
79 | return;
80 | }
81 | else {
82 | // Save to DOM data
83 | this.$tableWrapper.data('freeze-table-data', this.options);
84 | }
85 |
86 | /**
87 | * Options Setting
88 | */
89 | var options = this.options;
90 | var freezeHead = (typeof options.freezeHead !== 'undefined') ? options.freezeHead : true;
91 | var freezeColumn = (typeof options.freezeColumn !== 'undefined') ? options.freezeColumn : true;
92 | var freezeColumnHead = (typeof options.freezeColumnHead !== 'undefined') ? options.freezeColumnHead : true;
93 | var scrollBar = (typeof options.scrollBar !== 'undefined') ? options.scrollBar : false;
94 | var fixedNavbar = options.fixedNavbar || '.navbar-fixed-top';
95 | var callback = options.callback || null;
96 | this.namespace = this.options.namespace || this.namespace;
97 | // Default to get window scroll bar height
98 | this.scrollBarHeight = ($.isNumeric(options.scrollBarHeight)) ? options.scrollBarHeight : (window.innerWidth - document.documentElement.clientWidth);
99 | this.shadow = (typeof options.shadow !== 'undefined') ? options.shadow : false;
100 | this.fastMode = (typeof options.fastMode !== 'undefined') ? options.fastMode : false;
101 | this.backgroundColor = (typeof options.backgroundColor !== 'undefined') ? options.backgroundColor : 'white';
102 | this.scrollable = (typeof options.scrollable !== 'undefined') ? options.scrollable : false;
103 |
104 | // Get navbar height for keeping fixed navbar
105 | this.fixedNavbarHeight = (fixedNavbar) ? $(fixedNavbar).outerHeight() || 0 : 0;
106 |
107 | // Check existence
108 | if (this.isInit()) {
109 | this.destroy();
110 | }
111 |
112 | // Release height of the table wrapper
113 | if (!this.scrollable) {
114 | this.$tableWrapper.css('height', '100%')
115 | .css('min-height', '100%')
116 | .css('max-height', '100%');
117 | }
118 |
119 | /**
120 | * Building
121 | */
122 | // Switch for freezeHead
123 | if (freezeHead) {
124 | this.buildHeadTable();
125 | }
126 | // Switch for freezeColumn
127 | if (freezeColumn) {
128 | this.buildColumnTable();
129 | // X scroll bar
130 | this.$tableWrapper.css('overflow-x', 'scroll');
131 | }
132 | // Switch for freezeColumnHead
133 | if (freezeColumnHead && freezeHead && freezeColumn) {
134 | this.buildColumnHeadTable();
135 | }
136 | // Switch for scrollBar
137 | if (scrollBar) {
138 | this.buildScrollBar();
139 | }
140 |
141 | // Body scroll-x prevention
142 | var detectWindowScroll = (function (){
143 | // If body scroll-x is opened, close library to prevent Invalid usage
144 | if (this.$container.scrollLeft() > 0) {
145 | // Mark
146 | this.isWindowScrollX = true;
147 | // Hide all components
148 | if (this.$headTableWrap) {
149 | this.$headTableWrap.css('visibility', 'hidden');
150 | }
151 | if (this.$columnTableWrap) {
152 | this.$columnTableWrap.css('visibility', 'hidden');
153 | }
154 | if (this.$columnHeadTableWrap) {
155 | this.$columnHeadTableWrap.css('visibility', 'hidden');
156 | }
157 | if (this.$scrollBarWrap) {
158 | this.$scrollBarWrap.css('visibility', 'hidden');
159 | }
160 |
161 | } else {
162 | // Unmark
163 | this.isWindowScrollX = false;
164 | }
165 |
166 | }).bind(this);
167 | // Listener of Body scroll-x prevention
168 | this.$container.on('scroll.'+this.namespace, function () {
169 |
170 | detectWindowScroll();
171 | });
172 |
173 | // Initialization
174 | this.resize();
175 |
176 | // Callback
177 | if (typeof callback === 'function') {
178 | callback();
179 | }
180 | }
181 |
182 | /**
183 | * Freeze thead table
184 | */
185 | FreezeTable.prototype.buildHeadTable = function() {
186 |
187 | var that = this;
188 |
189 | // Clone the table as Fixed thead
190 | var $headTable = this.clone(this.$table);
191 |
192 | // Fast Mode
193 | if (this.fastMode) {
194 | var $headTable = this.simplifyHead($headTable);
195 | }
196 |
197 | var headWrapStyles = this.options.headWrapStyles || null;
198 | // Wrap the Fixed Column table
199 | this.$headTableWrap = $('')
200 | .append($headTable)
201 | .css('position', 'fixed')
202 | .css('overflow', 'hidden')
203 | .css('visibility', 'hidden')
204 | .css('top', 0 + this.fixedNavbarHeight)
205 | .css('z-index', 2);
206 | // Shadow option
207 | if (this.shadow) {
208 | this.$headTableWrap.css('box-shadow', '0px 6px 10px -5px rgba(159, 159, 160, 0.8)');
209 | }
210 | // Styles option
211 | if (headWrapStyles && typeof headWrapStyles === "object") {
212 | $.each(headWrapStyles, function(key, value) {
213 | that.$headTableWrap.css(key, value);
214 | });
215 | }
216 | // Add into target table wrap
217 | this.$tableWrapper.append(this.$headTableWrap);
218 |
219 | /**
220 | * Listener - Table scroll for effecting Freeze Column
221 | */
222 | this.$tableWrapper.on('scroll.'+this.namespace, function() {
223 |
224 | // this.$headTableWrap.css('left', this.$table.offset().left);
225 | that.$headTableWrap.scrollLeft($(this).scrollLeft());
226 | });
227 |
228 | // Scrollable option
229 | if (this.scrollable) {
230 |
231 | var handler = function (window, that) {
232 |
233 | var top = that.$tableWrapper.offset().top;
234 |
235 | // Detect Current container's top is in the table scope
236 | if (that.$tableWrapper.scrollTop() > 0 && top > that.fixedNavbarHeight) {
237 |
238 | that.$headTableWrap.offset({top: top});
239 | that.$headTableWrap.css('visibility', 'visible');
240 |
241 | } else {
242 |
243 | that.$headTableWrap.css('visibility', 'hidden');
244 | }
245 | }
246 |
247 | /**
248 | * Listener - Window scroll for effecting freeze head table
249 | */
250 | this.$tableWrapper.on('scroll.'+this.namespace, function() {
251 |
252 | handler(window, that);
253 | });
254 |
255 | this.$container.on('scroll.'+this.namespace, function() {
256 |
257 | handler(window, that);
258 | });
259 |
260 | }
261 | // Default with window container
262 | else if ($.isWindow(that.$container.get(0))) {
263 |
264 | /**
265 | * Listener - Window scroll for effecting freeze head table
266 | */
267 | this.$container.on('scroll.'+this.namespace, function() {
268 |
269 | // Current container's top position
270 | var topPosition = that.$container.scrollTop() + that.fixedNavbarHeight;
271 | var tableTop = that.$table.offset().top - 1;
272 |
273 | // Detect Current container's top is in the table scope
274 | if (tableTop - 1 <= topPosition && (tableTop + that.$table.outerHeight() - 1) >= topPosition) {
275 |
276 | that.$headTableWrap.css('visibility', 'visible');
277 |
278 | } else {
279 |
280 | that.$headTableWrap.css('visibility', 'hidden');
281 | }
282 | });
283 | }
284 | // Container setting
285 | else {
286 |
287 | /**
288 | * Listener - Window scroll for effecting freeze head table
289 | */
290 | this.$container.on('scroll.'+this.namespace, function() {
291 |
292 | var windowTop = $(window).scrollTop();
293 | var tableTop = that.$table.offset().top - 1;
294 |
295 | // Detect Current container's top is in the table scope
296 | if (tableTop <= windowTop && (tableTop + that.$table.outerHeight() - 1) >= windowTop) {
297 |
298 | that.$headTableWrap.offset({top: windowTop});
299 | that.$headTableWrap.css('visibility', 'visible');
300 |
301 | } else {
302 |
303 | that.$headTableWrap.css('visibility', 'hidden');
304 | }
305 | });
306 | }
307 |
308 | /**
309 | * Listener - Window resize for effecting freeze head table
310 | */
311 | this.$container.on('resize.'+this.namespace, function() {
312 |
313 | // Scrollable check and prevention
314 | var headTableWrapWidth = (that.scrollable) ? that.$tableWrapper.width() - that.scrollBarHeight : that.$tableWrapper.width();
315 | headTableWrapWidth = (headTableWrapWidth > 0) ? headTableWrapWidth : that.$tableWrapper.width();
316 | that.$headTableWrap.css('width', headTableWrapWidth);
317 | that.$headTableWrap.css('height', that.$table.find("thead").outerHeight());
318 | });
319 | }
320 |
321 | /**
322 | * Freeze column table
323 | */
324 | FreezeTable.prototype.buildColumnTable = function() {
325 |
326 | var that = this;
327 |
328 | /**
329 | * Setting
330 | */
331 | var columnWrapStyles = this.options.columnWrapStyles || null;
332 | var columnNum = this.options.columnNum || 1;
333 | var columnKeep = (typeof this.options.columnKeep !== 'undefined') ? this.options.columnKeep : false;
334 | // Shadow option
335 | var defaultColumnBorderWidth = (this.shadow) ? 0 : 1;
336 | var columnBorderWidth = (typeof this.options.columnBorderWidth !== 'undefined') ? this.options.columnBorderWidth : defaultColumnBorderWidth;
337 |
338 | // Clone the table as Fixed Column table
339 | var $columnTable = this.clone(this.$table);
340 |
341 | // Wrap the Fixed Column table
342 | this.$columnTableWrap = $('')
343 | .append($columnTable)
344 | .css('position', 'fixed')
345 | .css('overflow', 'hidden')
346 | .css('visibility', 'hidden')
347 | .css('z-index', 1);
348 | // Shadow option
349 | if (this.shadow) {
350 | this.$columnTableWrap.css('box-shadow', '6px 0px 10px -5px rgba(159, 159, 160, 0.8)');
351 | }
352 | // Styles option
353 | if (columnWrapStyles && typeof columnWrapStyles === "object") {
354 | $.each(columnWrapStyles, function(key, value) {
355 | that.$columnTableWrap.css(key, value);
356 | });
357 | }
358 | // Scrollable
359 | if (this.scrollable) {
360 | // Scrollable check and prevention
361 | var columnTableWrapHeight = this.$tableWrapper.height() - this.scrollBarHeight;
362 | columnTableWrapHeight = (columnTableWrapHeight > 0) ? columnTableWrapHeight : this.$tableWrapper.height();
363 | this.$columnTableWrap.height(columnTableWrapHeight);
364 | }
365 | // Add into target table wrap
366 | this.$tableWrapper.append(this.$columnTableWrap);
367 |
368 | /**
369 | * localize the column wrap to current top
370 | */
371 | var localizeWrap = function () {
372 |
373 | that.$columnTableWrap.offset({top: that.$tableWrapper.offset().top});
374 | }
375 |
376 | // Column keep option
377 | if (columnKeep) {
378 |
379 | this.$columnTableWrap.css('visibility', 'visible');
380 |
381 | } else {
382 |
383 | // Scrollable option
384 | if (that.scrollable) {
385 |
386 | /**
387 | * Listener - Table scroll for effecting Freeze Column
388 | */
389 | this.$tableWrapper.on('scroll.'+this.namespace, function() {
390 |
391 |
392 | // Detect for horizontal scroll
393 | if ($(this).scrollLeft() > 0) {
394 |
395 | // Scrollable localization
396 | that.$columnTableWrap.scrollTop(that.$tableWrapper.scrollTop());
397 | that.$columnTableWrap.css('visibility', 'visible');
398 |
399 | } else {
400 |
401 | that.$columnTableWrap.css('visibility', 'hidden');
402 | }
403 | });
404 |
405 | } else {
406 |
407 | /**
408 | * Listener - Table scroll for effecting Freeze Column
409 | */
410 | this.$tableWrapper.on('scroll.'+this.namespace, function() {
411 |
412 | // Disable while isWindowScrollX
413 | if (that.isWindowScrollX)
414 | return;
415 |
416 | // Detect for horizontal scroll
417 | if ($(this).scrollLeft() > 0) {
418 |
419 | that.$columnTableWrap.css('visibility', 'visible');
420 |
421 | } else {
422 |
423 | that.$columnTableWrap.css('visibility', 'hidden');
424 | }
425 | });
426 | }
427 | }
428 |
429 | /**
430 | * Listener - Window resize for effecting tables
431 | */
432 | this.$container.on('resize.'+this.namespace, function() {
433 |
434 | // Follows origin table's width
435 | $columnTable.width(that.$table.width());
436 |
437 | /**
438 | * Dynamic column calculation
439 | */
440 | // Get width by fixed column with number setting
441 | var width = 0 + columnBorderWidth;
442 | for (var i = 1; i <= columnNum; i++) {
443 | // th/td detection
444 | var th = that.$table.find('th:nth-child('+i+')').outerWidth();
445 | var addWidth = (th > 0) ? th : that.$table.find('td:nth-child('+i+')').outerWidth();
446 | width += addWidth;
447 | }
448 | that.$columnTableWrap.width(width);
449 |
450 | localizeWrap();
451 | });
452 |
453 | /**
454 | * Listener - Window scroll for effecting freeze column table
455 | */
456 | this.$container.on('scroll.'+this.namespace, function() {
457 |
458 | localizeWrap();
459 | });
460 | }
461 |
462 | /**
463 | * Freeze column thead table
464 | */
465 | FreezeTable.prototype.buildColumnHeadTable = function() {
466 |
467 | var that = this;
468 |
469 | // Clone head table wrap
470 | this.$columnHeadTableWrap = this.clone(this.$headTableWrap);
471 |
472 | // Fast Mode
473 | if (this.fastMode) {
474 | this.$columnHeadTableWrap = this.simplifyHead(this.$columnHeadTableWrap);
475 | }
476 |
477 | var columnHeadWrapStyles = this.options.columnHeadWrapStyles || null;
478 |
479 | this.$columnHeadTableWrap.removeClass(this.namespace)
480 | .addClass(this.columnHeadWrapClass)
481 | .css('z-index', 3);
482 | // Shadow option
483 | if (this.shadow) {
484 | this.$columnHeadTableWrap.css('box-shadow', 'none');
485 | }
486 | // Styles option
487 | if (columnHeadWrapStyles && typeof columnHeadWrapStyles === "object") {
488 | $.each(columnHeadWrapStyles, function(key, value) {
489 | this.$columnHeadTableWrap.css(key, value);
490 | });
491 | }
492 |
493 | // Add into target table wrap
494 | this.$tableWrapper.append(this.$columnHeadTableWrap);
495 |
496 | // Scrollable option
497 | if (this.scrollable) {
498 |
499 | var detect = function () {
500 |
501 | var top = that.$tableWrapper.offset().top;
502 |
503 | // Detect Current container's top is in the table scope
504 | if (that.$tableWrapper.scrollTop() > 0 && top > that.fixedNavbarHeight) {
505 |
506 | that.$columnHeadTableWrap.offset({top: top});
507 | that.$columnHeadTableWrap.css('visibility', 'visible');
508 |
509 | } else {
510 |
511 | that.$columnHeadTableWrap.css('visibility', 'hidden');
512 | }
513 | }
514 |
515 | /**
516 | * Listener - Window scroll for effecting freeze head table
517 | */
518 | $(this.$tableWrapper).on('scroll.'+this.namespace, function() {
519 |
520 | detect();
521 | });
522 |
523 | }
524 | // Default with window container
525 | else if ($.isWindow(this.$container.get(0))) {
526 |
527 | var detect = function () {
528 |
529 | // Current container's top position
530 | var topPosition = that.$container.scrollTop() + that.fixedNavbarHeight;
531 | var tableTop = that.$table.offset().top - 1;
532 |
533 | // Detect Current container's top is in the table scope
534 | if (tableTop - 1 <= topPosition && (tableTop + that.$table.outerHeight() - 1) >= topPosition && that.$tableWrapper.scrollLeft() > 0) {
535 |
536 | that.$columnHeadTableWrap.css('visibility', 'visible');
537 |
538 | } else {
539 |
540 | that.$columnHeadTableWrap.css('visibility', 'hidden');
541 | }
542 | }
543 | }
544 | // Container setting
545 | else {
546 |
547 | var detect = function () {
548 |
549 | var windowTop = $(window).scrollTop();
550 | var tableTop = that.$table.offset().top - 1;
551 |
552 | // Detect Current container's top is in the table scope
553 | if (tableTop <= windowTop && (tableTop + that.$table.outerHeight() - 1) >= windowTop && that.$tableWrapper.scrollLeft() > 0) {
554 |
555 | that.$columnHeadTableWrap.offset({top: windowTop});
556 | that.$columnHeadTableWrap.css('visibility', 'visible');
557 |
558 | } else {
559 |
560 | that.$columnHeadTableWrap.css('visibility', 'hidden');
561 | }
562 | }
563 | }
564 |
565 | /**
566 | * Listener - Window scroll for effecting Freeze column-head table
567 | */
568 | this.$container.on('scroll.'+this.namespace, function() {
569 |
570 | detect();
571 | });
572 |
573 | /**
574 | * Listener - Table scroll for effecting Freeze column-head table
575 | */
576 | this.$tableWrapper.on('scroll.'+this.namespace, function() {
577 |
578 | // Disable while isWindowScrollX
579 | if (that.isWindowScrollX)
580 | return;
581 |
582 | detect();
583 | });
584 |
585 | /**
586 | * Listener - Window resize for effecting freeze column-head table
587 | */
588 | this.$container.on('resize.'+this.namespace, function() {
589 |
590 | // Table synchronism
591 | that.$columnHeadTableWrap.find("> table").css('width', that.$table.width());
592 | that.$columnHeadTableWrap.css('width', that.$columnTableWrap.width());
593 | that.$columnHeadTableWrap.css('height', that.$table.find("thead").outerHeight());
594 | });
595 | }
596 |
597 | /**
598 | * Freeze scroll bar
599 | */
600 | FreezeTable.prototype.buildScrollBar = function() {
601 |
602 | var that = this;
603 |
604 | var theadHeight = this.$table.find("thead").outerHeight();
605 |
606 | // Scroll wrap container
607 | var $scrollBarContainer = $('')
608 | .css('width', this.$table.width())
609 | .css('height', 1);
610 |
611 | // Wrap the Fixed Column table
612 | this.$scrollBarWrap = $('')
613 | .css('position', 'fixed')
614 | .css('overflow-x', 'scroll')
615 | .css('visibility', 'hidden')
616 | .css('bottom', 0)
617 | .css('z-index', 2)
618 | .css('width', this.$tableWrapper.width())
619 | .css('height', this.scrollBarHeight);
620 |
621 | // Add into target table wrap
622 | this.$scrollBarWrap.append($scrollBarContainer);
623 | this.$tableWrapper.append(this.$scrollBarWrap);
624 |
625 | /**
626 | * Listener - Freeze scroll bar effected Table
627 | */
628 | this.$scrollBarWrap.on('scroll.'+this.namespace, function() {
629 |
630 | that.$tableWrapper.scrollLeft($(this).scrollLeft());
631 | });
632 |
633 | /**
634 | * Listener - Table scroll for effecting Freeze scroll bar
635 | */
636 | this.$tableWrapper.on('scroll.'+this.namespace, function() {
637 |
638 | // this.$headTableWrap.css('left', $table.offset().left);
639 | that.$scrollBarWrap.scrollLeft($(this).scrollLeft());
640 | });
641 |
642 | /**
643 | * Listener - Window scroll for effecting scroll bar
644 | */
645 | this.$container.on('scroll.'+this.namespace, function() {
646 |
647 | // Current container's top position
648 | var bottomPosition = that.$container.scrollTop() + that.$container.height() - theadHeight + that.fixedNavbarHeight;
649 |
650 | // Detect Current container's top is in the table scope
651 | if (that.$table.offset().top - 1 <= bottomPosition && (that.$table.offset().top + that.$table.outerHeight() - 1) >= bottomPosition) {
652 |
653 | that.$scrollBarWrap.css('visibility', 'visible');
654 |
655 | } else {
656 |
657 | that.$scrollBarWrap.css('visibility', 'hidden');
658 | }
659 | });
660 |
661 | /**
662 | * Listener - Window resize for effecting scroll bar
663 | */
664 | this.$container.on('resize.'+this.namespace, function() {
665 |
666 | // Update width
667 | $scrollBarContainer.css('width', that.$table.width())
668 | // Update Wrap
669 | that.$scrollBarWrap.css('width', that.$tableWrapper.width());
670 | });
671 | }
672 |
673 | /**
674 | * Clone element
675 | *
676 | * @param {element} element
677 | */
678 | FreezeTable.prototype.clone = function (element) {
679 |
680 | var $clone = $(element).clone()
681 | .removeAttr('id') // Remove ID
682 |
683 | // Bootstrap background-color transparent problem
684 | if (this.backgroundColor) {
685 | $clone.css('background-color', this.backgroundColor);
686 | }
687 |
688 | return $clone;
689 | }
690 |
691 | /**
692 | * simplify cloned head table
693 | *
694 | * @param {element} table Table element
695 | */
696 | FreezeTable.prototype.simplifyHead = function (table) {
697 |
698 | var that = this;
699 |
700 | var $headTable = $(table);
701 | // Remove non-display DOM but keeping first row for accuracy
702 | $headTable.find("> tr, > tbody > tr, tfoot > tr").not(':first').remove();
703 | // Each th/td width synchronism
704 | $.each($headTable.find("> thead > tr:nth-child(1) >"), function (key, value) {
705 |
706 | var width = that.$table.find("> thead > tr:nth-child(1) > :nth-child("+parseInt(key+1)+")").outerWidth();
707 | $(this).css('width', width);
708 | });
709 |
710 | return $headTable;
711 | }
712 |
713 | /**
714 | * Detect is already initialized
715 | */
716 | FreezeTable.prototype.isInit = function() {
717 |
718 | // Check existence DOM
719 | if (this.$tableWrapper.find("."+this.headWrapClass).length)
720 | return true;
721 | if (this.$tableWrapper.find("."+this.columnWrapClass).length)
722 | return true;
723 | if (this.$tableWrapper.find("."+this.columnHeadWrapClass).length)
724 | return true;
725 | if (this.$tableWrapper.find("."+this.scrollBarWrapClass).length)
726 | return true;
727 |
728 | return false;
729 |
730 | }
731 |
732 | /**
733 | * Unbind all events by same namespace
734 | */
735 | FreezeTable.prototype.unbind = function() {
736 |
737 | this.$container.off('resize.'+this.namespace);
738 | this.$container.off('scroll.'+this.namespace);
739 | this.$tableWrapper.off('scroll.'+this.namespace);
740 | }
741 |
742 | /**
743 | * Destroy Freeze Table by same namespace
744 | */
745 | FreezeTable.prototype.destroy = function() {
746 |
747 | this.unbind();
748 | this.$tableWrapper.find("."+this.headWrapClass).remove();
749 | this.$tableWrapper.find("."+this.columnWrapClass).remove();
750 | this.$tableWrapper.find("."+this.columnHeadWrapClass).remove();
751 | this.$tableWrapper.find("."+this.scrollBarWrapClass).remove();
752 | }
753 |
754 | /**
755 | * Resize trigger for current same namespace
756 | */
757 | FreezeTable.prototype.resize = function() {
758 |
759 | this.$container.trigger('resize.'+this.namespace);
760 | this.$container.trigger('scroll.'+this.namespace);
761 | this.$tableWrapper.trigger('scroll.'+this.namespace);
762 |
763 | return true;
764 | }
765 |
766 | /**
767 | * Update for Dynamic Content
768 | */
769 | FreezeTable.prototype.update = function() {
770 |
771 | // Same as re-new object
772 | this.options = 'update';
773 | this.init();
774 | return this;
775 | }
776 |
777 | /**
778 | * Interface
779 | */
780 | // Class for single element
781 | window.FreezeTable = FreezeTable;
782 | // jQuery interface
783 | $.fn.freezeTable = function (options) {
784 |
785 | // Single/Multiple mode
786 | if (this.length === 1) {
787 |
788 | return new FreezeTable(this, options)
789 | }
790 | else if (this.length > 1) {
791 |
792 | var result = [];
793 | // Multiple elements bundle
794 | this.each(function () {
795 | result.push(new FreezeTable(this, options));
796 | });
797 |
798 | return result;
799 | }
800 |
801 | return false;
802 | }
803 |
804 | })(jQuery, window);
805 |
--------------------------------------------------------------------------------
/src/js/freeze-table.js:
--------------------------------------------------------------------------------
1 | /**
2 | * RWD Table with freezing head and columns for jQuery
3 | *
4 | * @author Nick Tsai
5 | * @version 1.3.0
6 | * @see https://github.com/yidas/jquery-freeze-table
7 | */
8 | (function ($, window) {
9 |
10 | 'use strict';
11 |
12 | /**
13 | * Main object
14 | *
15 | * @param {element} element
16 | * @param {object} options
17 | */
18 | var FreezeTable = function(element, options) {
19 |
20 | // Target element initialization
21 | this.$tableWrapper = $(element).first();
22 |
23 | // Options
24 | this.options = options || {};
25 | this.namespace = this.options.namespace || 'freeze-table';
26 | this.callback;
27 | this.scrollBarHeight;
28 | this.shadow;
29 | this.fastMode;
30 | this.backgroundColor;
31 | this.scrollable;
32 |
33 | // Caches
34 | this.$table = this.$tableWrapper.children("table");
35 | this.$container = ((typeof this.options.container !== 'undefined') && this.options.container && $(this.options.container).length) ? $(this.options.container) : $(window);
36 | this.$headTableWrap;
37 | this.$columnTableWrap;
38 | this.$columnHeadTableWrap;
39 | this.$scrollBarWrap;
40 | this.fixedNavbarHeight;
41 | this.isWindowScrollX = false;
42 |
43 | // Static class names for clone wraps
44 | this.headWrapClass = 'clone-head-table-wrap';
45 | this.columnWrapClass = 'clone-column-table-wrap';
46 | this.columnHeadWrapClass = 'clone-column-head-table-wrap';
47 | this.scrollBarWrapClass = 'clone-scroll-bar-wrap';
48 |
49 | this.init();
50 |
51 | return this;
52 | }
53 |
54 | /**
55 | * Initialization
56 | */
57 | FreezeTable.prototype.init = function() {
58 |
59 | // Element check
60 | if (!this.$table.length) {
61 | throw "The element must contain a table dom";
62 | }
63 |
64 | /**
65 | * Update Mode
66 | */
67 | if (this.options==='update') {
68 |
69 | this.destroy();
70 | this.options = this.$tableWrapper.data('freeze-table-data');
71 | }
72 | else if (this.options==='resize') {
73 |
74 | this.options = this.$tableWrapper.data('freeze-table-data');
75 | // Get selected FreezeTable's namespace
76 | this.namespace = this.options.namespace || this.namespace;
77 | this.resize();
78 | // Skip init for better performance usage
79 | return;
80 | }
81 | else {
82 | // Save to DOM data
83 | this.$tableWrapper.data('freeze-table-data', this.options);
84 | }
85 |
86 | /**
87 | * Options Setting
88 | */
89 | var options = this.options;
90 | var freezeHead = (typeof options.freezeHead !== 'undefined') ? options.freezeHead : true;
91 | var freezeColumn = (typeof options.freezeColumn !== 'undefined') ? options.freezeColumn : true;
92 | var freezeColumnHead = (typeof options.freezeColumnHead !== 'undefined') ? options.freezeColumnHead : true;
93 | var scrollBar = (typeof options.scrollBar !== 'undefined') ? options.scrollBar : false;
94 | var fixedNavbar = options.fixedNavbar || '.navbar-fixed-top';
95 | var callback = options.callback || null;
96 | this.namespace = this.options.namespace || this.namespace;
97 | // Default to get window scroll bar height
98 | this.scrollBarHeight = ($.isNumeric(options.scrollBarHeight)) ? options.scrollBarHeight : (window.innerWidth - document.documentElement.clientWidth);
99 | this.shadow = (typeof options.shadow !== 'undefined') ? options.shadow : false;
100 | this.fastMode = (typeof options.fastMode !== 'undefined') ? options.fastMode : false;
101 | this.backgroundColor = (typeof options.backgroundColor !== 'undefined') ? options.backgroundColor : 'white';
102 | this.scrollable = (typeof options.scrollable !== 'undefined') ? options.scrollable : false;
103 |
104 | // Get navbar height for keeping fixed navbar
105 | this.fixedNavbarHeight = (fixedNavbar) ? $(fixedNavbar).outerHeight() || 0 : 0;
106 |
107 | // Check existence
108 | if (this.isInit()) {
109 | this.destroy();
110 | }
111 |
112 | // Release height of the table wrapper
113 | if (!this.scrollable) {
114 | this.$tableWrapper.css('height', '100%')
115 | .css('min-height', '100%')
116 | .css('max-height', '100%');
117 | }
118 |
119 | /**
120 | * Building
121 | */
122 | // Switch for freezeHead
123 | if (freezeHead) {
124 | this.buildHeadTable();
125 | }
126 | // Switch for freezeColumn
127 | if (freezeColumn) {
128 | this.buildColumnTable();
129 | // X scroll bar
130 | this.$tableWrapper.css('overflow-x', 'scroll');
131 | }
132 | // Switch for freezeColumnHead
133 | if (freezeColumnHead && freezeHead && freezeColumn) {
134 | this.buildColumnHeadTable();
135 | }
136 | // Switch for scrollBar
137 | if (scrollBar) {
138 | this.buildScrollBar();
139 | }
140 |
141 | // Body scroll-x prevention
142 | var detectWindowScroll = (function (){
143 | // If body scroll-x is opened, close library to prevent Invalid usage
144 | if (this.$container.scrollLeft() > 0) {
145 | // Mark
146 | this.isWindowScrollX = true;
147 | // Hide all components
148 | if (this.$headTableWrap) {
149 | this.$headTableWrap.css('visibility', 'hidden');
150 | }
151 | if (this.$columnTableWrap) {
152 | this.$columnTableWrap.css('visibility', 'hidden');
153 | }
154 | if (this.$columnHeadTableWrap) {
155 | this.$columnHeadTableWrap.css('visibility', 'hidden');
156 | }
157 | if (this.$scrollBarWrap) {
158 | this.$scrollBarWrap.css('visibility', 'hidden');
159 | }
160 |
161 | } else {
162 | // Unmark
163 | this.isWindowScrollX = false;
164 | }
165 |
166 | }).bind(this);
167 | // Listener of Body scroll-x prevention
168 | this.$container.on('scroll.'+this.namespace, function () {
169 |
170 | detectWindowScroll();
171 | });
172 |
173 | // Initialization
174 | this.resize();
175 |
176 | // Callback
177 | if (typeof callback === 'function') {
178 | callback();
179 | }
180 | }
181 |
182 | /**
183 | * Freeze thead table
184 | */
185 | FreezeTable.prototype.buildHeadTable = function() {
186 |
187 | var that = this;
188 |
189 | // Clone the table as Fixed thead
190 | var $headTable = this.clone(this.$table);
191 |
192 | // Fast Mode
193 | if (this.fastMode) {
194 | var $headTable = this.simplifyHead($headTable);
195 | }
196 |
197 | var headWrapStyles = this.options.headWrapStyles || null;
198 | // Wrap the Fixed Column table
199 | this.$headTableWrap = $('')
200 | .append($headTable)
201 | .css('position', 'fixed')
202 | .css('overflow', 'hidden')
203 | .css('visibility', 'hidden')
204 | .css('top', 0 + this.fixedNavbarHeight)
205 | .css('z-index', 2);
206 | // Shadow option
207 | if (this.shadow) {
208 | this.$headTableWrap.css('box-shadow', '0px 6px 10px -5px rgba(159, 159, 160, 0.8)');
209 | }
210 | // Styles option
211 | if (headWrapStyles && typeof headWrapStyles === "object") {
212 | $.each(headWrapStyles, function(key, value) {
213 | that.$headTableWrap.css(key, value);
214 | });
215 | }
216 | // Add into target table wrap
217 | this.$tableWrapper.append(this.$headTableWrap);
218 |
219 | /**
220 | * Listener - Table scroll for effecting Freeze Column
221 | */
222 | this.$tableWrapper.on('scroll.'+this.namespace, function() {
223 |
224 | // this.$headTableWrap.css('left', this.$table.offset().left);
225 | that.$headTableWrap.scrollLeft($(this).scrollLeft());
226 | });
227 |
228 | // Scrollable option
229 | if (this.scrollable) {
230 |
231 | var handler = function (window, that) {
232 |
233 | var top = that.$tableWrapper.offset().top;
234 |
235 | // Detect Current container's top is in the table scope
236 | if (that.$tableWrapper.scrollTop() > 0 && top > that.fixedNavbarHeight) {
237 |
238 | that.$headTableWrap.offset({top: top});
239 | that.$headTableWrap.css('visibility', 'visible');
240 |
241 | } else {
242 |
243 | that.$headTableWrap.css('visibility', 'hidden');
244 | }
245 | }
246 |
247 | /**
248 | * Listener - Window scroll for effecting freeze head table
249 | */
250 | this.$tableWrapper.on('scroll.'+this.namespace, function() {
251 |
252 | handler(window, that);
253 | });
254 |
255 | this.$container.on('scroll.'+this.namespace, function() {
256 |
257 | handler(window, that);
258 | });
259 |
260 | }
261 | // Default with window container
262 | else if ($.isWindow(that.$container.get(0))) {
263 |
264 | /**
265 | * Listener - Window scroll for effecting freeze head table
266 | */
267 | this.$container.on('scroll.'+this.namespace, function() {
268 |
269 | // Current container's top position
270 | var topPosition = that.$container.scrollTop() + that.fixedNavbarHeight;
271 | var tableTop = that.$table.offset().top - 1;
272 |
273 | // Detect Current container's top is in the table scope
274 | if (tableTop - 1 <= topPosition && (tableTop + that.$table.outerHeight() - 1) >= topPosition) {
275 |
276 | that.$headTableWrap.css('visibility', 'visible');
277 |
278 | } else {
279 |
280 | that.$headTableWrap.css('visibility', 'hidden');
281 | }
282 | });
283 | }
284 | // Container setting
285 | else {
286 |
287 | /**
288 | * Listener - Window scroll for effecting freeze head table
289 | */
290 | this.$container.on('scroll.'+this.namespace, function() {
291 |
292 | var windowTop = $(window).scrollTop();
293 | var tableTop = that.$table.offset().top - 1;
294 |
295 | // Detect Current container's top is in the table scope
296 | if (tableTop <= windowTop && (tableTop + that.$table.outerHeight() - 1) >= windowTop) {
297 |
298 | that.$headTableWrap.offset({top: windowTop});
299 | that.$headTableWrap.css('visibility', 'visible');
300 |
301 | } else {
302 |
303 | that.$headTableWrap.css('visibility', 'hidden');
304 | }
305 | });
306 | }
307 |
308 | /**
309 | * Listener - Window resize for effecting freeze head table
310 | */
311 | this.$container.on('resize.'+this.namespace, function() {
312 |
313 | // Scrollable check and prevention
314 | var headTableWrapWidth = (that.scrollable) ? that.$tableWrapper.width() - that.scrollBarHeight : that.$tableWrapper.width();
315 | headTableWrapWidth = (headTableWrapWidth > 0) ? headTableWrapWidth : that.$tableWrapper.width();
316 | that.$headTableWrap.css('width', headTableWrapWidth);
317 | that.$headTableWrap.css('height', that.$table.find("thead").outerHeight());
318 | });
319 | }
320 |
321 | /**
322 | * Freeze column table
323 | */
324 | FreezeTable.prototype.buildColumnTable = function() {
325 |
326 | var that = this;
327 |
328 | /**
329 | * Setting
330 | */
331 | var columnWrapStyles = this.options.columnWrapStyles || null;
332 | var columnNum = this.options.columnNum || 1;
333 | var columnKeep = (typeof this.options.columnKeep !== 'undefined') ? this.options.columnKeep : false;
334 | // Shadow option
335 | var defaultColumnBorderWidth = (this.shadow) ? 0 : 1;
336 | var columnBorderWidth = (typeof this.options.columnBorderWidth !== 'undefined') ? this.options.columnBorderWidth : defaultColumnBorderWidth;
337 |
338 | // Clone the table as Fixed Column table
339 | var $columnTable = this.clone(this.$table);
340 |
341 | // Wrap the Fixed Column table
342 | this.$columnTableWrap = $('')
343 | .append($columnTable)
344 | .css('position', 'fixed')
345 | .css('overflow', 'hidden')
346 | .css('visibility', 'hidden')
347 | .css('z-index', 1);
348 | // Shadow option
349 | if (this.shadow) {
350 | this.$columnTableWrap.css('box-shadow', '6px 0px 10px -5px rgba(159, 159, 160, 0.8)');
351 | }
352 | // Styles option
353 | if (columnWrapStyles && typeof columnWrapStyles === "object") {
354 | $.each(columnWrapStyles, function(key, value) {
355 | that.$columnTableWrap.css(key, value);
356 | });
357 | }
358 | // Scrollable
359 | if (this.scrollable) {
360 | // Scrollable check and prevention
361 | var columnTableWrapHeight = this.$tableWrapper.height() - this.scrollBarHeight;
362 | columnTableWrapHeight = (columnTableWrapHeight > 0) ? columnTableWrapHeight : this.$tableWrapper.height();
363 | this.$columnTableWrap.height(columnTableWrapHeight);
364 | }
365 | // Add into target table wrap
366 | this.$tableWrapper.append(this.$columnTableWrap);
367 |
368 | /**
369 | * localize the column wrap to current top
370 | */
371 | var localizeWrap = function () {
372 |
373 | that.$columnTableWrap.offset({top: that.$tableWrapper.offset().top});
374 | }
375 |
376 | // Column keep option
377 | if (columnKeep) {
378 |
379 | this.$columnTableWrap.css('visibility', 'visible');
380 |
381 | } else {
382 |
383 | // Scrollable option
384 | if (that.scrollable) {
385 |
386 | /**
387 | * Listener - Table scroll for effecting Freeze Column
388 | */
389 | this.$tableWrapper.on('scroll.'+this.namespace, function() {
390 |
391 |
392 | // Detect for horizontal scroll
393 | if ($(this).scrollLeft() > 0) {
394 |
395 | // Scrollable localization
396 | that.$columnTableWrap.scrollTop(that.$tableWrapper.scrollTop());
397 | that.$columnTableWrap.css('visibility', 'visible');
398 |
399 | } else {
400 |
401 | that.$columnTableWrap.css('visibility', 'hidden');
402 | }
403 | });
404 |
405 | } else {
406 |
407 | /**
408 | * Listener - Table scroll for effecting Freeze Column
409 | */
410 | this.$tableWrapper.on('scroll.'+this.namespace, function() {
411 |
412 | // Disable while isWindowScrollX
413 | if (that.isWindowScrollX)
414 | return;
415 |
416 | // Detect for horizontal scroll
417 | if ($(this).scrollLeft() > 0) {
418 |
419 | that.$columnTableWrap.css('visibility', 'visible');
420 |
421 | } else {
422 |
423 | that.$columnTableWrap.css('visibility', 'hidden');
424 | }
425 | });
426 | }
427 | }
428 |
429 | /**
430 | * Listener - Window resize for effecting tables
431 | */
432 | this.$container.on('resize.'+this.namespace, function() {
433 |
434 | // Follows origin table's width
435 | $columnTable.width(that.$table.width());
436 |
437 | /**
438 | * Dynamic column calculation
439 | */
440 | // Get width by fixed column with number setting
441 | var width = 0 + columnBorderWidth;
442 | for (var i = 1; i <= columnNum; i++) {
443 | // th/td detection
444 | var th = that.$table.find('th:nth-child('+i+')').outerWidth();
445 | var addWidth = (th > 0) ? th : that.$table.find('td:nth-child('+i+')').outerWidth();
446 | width += addWidth;
447 | }
448 | that.$columnTableWrap.width(width);
449 |
450 | localizeWrap();
451 | });
452 |
453 | /**
454 | * Listener - Window scroll for effecting freeze column table
455 | */
456 | this.$container.on('scroll.'+this.namespace, function() {
457 |
458 | localizeWrap();
459 | });
460 | }
461 |
462 | /**
463 | * Freeze column thead table
464 | */
465 | FreezeTable.prototype.buildColumnHeadTable = function() {
466 |
467 | var that = this;
468 |
469 | // Clone head table wrap
470 | this.$columnHeadTableWrap = this.clone(this.$headTableWrap);
471 |
472 | // Fast Mode
473 | if (this.fastMode) {
474 | this.$columnHeadTableWrap = this.simplifyHead(this.$columnHeadTableWrap);
475 | }
476 |
477 | var columnHeadWrapStyles = this.options.columnHeadWrapStyles || null;
478 |
479 | this.$columnHeadTableWrap.removeClass(this.namespace)
480 | .addClass(this.columnHeadWrapClass)
481 | .css('z-index', 3);
482 | // Shadow option
483 | if (this.shadow) {
484 | this.$columnHeadTableWrap.css('box-shadow', 'none');
485 | }
486 | // Styles option
487 | if (columnHeadWrapStyles && typeof columnHeadWrapStyles === "object") {
488 | $.each(columnHeadWrapStyles, function(key, value) {
489 | this.$columnHeadTableWrap.css(key, value);
490 | });
491 | }
492 |
493 | // Add into target table wrap
494 | this.$tableWrapper.append(this.$columnHeadTableWrap);
495 |
496 | // Scrollable option
497 | if (this.scrollable) {
498 |
499 | var detect = function () {
500 |
501 | var top = that.$tableWrapper.offset().top;
502 |
503 | // Detect Current container's top is in the table scope
504 | if (that.$tableWrapper.scrollTop() > 0 && top > that.fixedNavbarHeight) {
505 |
506 | that.$columnHeadTableWrap.offset({top: top});
507 | that.$columnHeadTableWrap.css('visibility', 'visible');
508 |
509 | } else {
510 |
511 | that.$columnHeadTableWrap.css('visibility', 'hidden');
512 | }
513 | }
514 |
515 | /**
516 | * Listener - Window scroll for effecting freeze head table
517 | */
518 | $(this.$tableWrapper).on('scroll.'+this.namespace, function() {
519 |
520 | detect();
521 | });
522 |
523 | }
524 | // Default with window container
525 | else if ($.isWindow(this.$container.get(0))) {
526 |
527 | var detect = function () {
528 |
529 | // Current container's top position
530 | var topPosition = that.$container.scrollTop() + that.fixedNavbarHeight;
531 | var tableTop = that.$table.offset().top - 1;
532 |
533 | // Detect Current container's top is in the table scope
534 | if (tableTop - 1 <= topPosition && (tableTop + that.$table.outerHeight() - 1) >= topPosition && that.$tableWrapper.scrollLeft() > 0) {
535 |
536 | that.$columnHeadTableWrap.css('visibility', 'visible');
537 |
538 | } else {
539 |
540 | that.$columnHeadTableWrap.css('visibility', 'hidden');
541 | }
542 | }
543 | }
544 | // Container setting
545 | else {
546 |
547 | var detect = function () {
548 |
549 | var windowTop = $(window).scrollTop();
550 | var tableTop = that.$table.offset().top - 1;
551 |
552 | // Detect Current container's top is in the table scope
553 | if (tableTop <= windowTop && (tableTop + that.$table.outerHeight() - 1) >= windowTop && that.$tableWrapper.scrollLeft() > 0) {
554 |
555 | that.$columnHeadTableWrap.offset({top: windowTop});
556 | that.$columnHeadTableWrap.css('visibility', 'visible');
557 |
558 | } else {
559 |
560 | that.$columnHeadTableWrap.css('visibility', 'hidden');
561 | }
562 | }
563 | }
564 |
565 | /**
566 | * Listener - Window scroll for effecting Freeze column-head table
567 | */
568 | this.$container.on('scroll.'+this.namespace, function() {
569 |
570 | detect();
571 | });
572 |
573 | /**
574 | * Listener - Table scroll for effecting Freeze column-head table
575 | */
576 | this.$tableWrapper.on('scroll.'+this.namespace, function() {
577 |
578 | // Disable while isWindowScrollX
579 | if (that.isWindowScrollX)
580 | return;
581 |
582 | detect();
583 | });
584 |
585 | /**
586 | * Listener - Window resize for effecting freeze column-head table
587 | */
588 | this.$container.on('resize.'+this.namespace, function() {
589 |
590 | // Table synchronism
591 | that.$columnHeadTableWrap.find("> table").css('width', that.$table.width());
592 | that.$columnHeadTableWrap.css('width', that.$columnTableWrap.width());
593 | that.$columnHeadTableWrap.css('height', that.$table.find("thead").outerHeight());
594 | });
595 | }
596 |
597 | /**
598 | * Freeze scroll bar
599 | */
600 | FreezeTable.prototype.buildScrollBar = function() {
601 |
602 | var that = this;
603 |
604 | var theadHeight = this.$table.find("thead").outerHeight();
605 |
606 | // Scroll wrap container
607 | var $scrollBarContainer = $('')
608 | .css('width', this.$table.width())
609 | .css('height', 1);
610 |
611 | // Wrap the Fixed Column table
612 | this.$scrollBarWrap = $('')
613 | .css('position', 'fixed')
614 | .css('overflow-x', 'scroll')
615 | .css('visibility', 'hidden')
616 | .css('bottom', 0)
617 | .css('z-index', 2)
618 | .css('width', this.$tableWrapper.width())
619 | .css('height', this.scrollBarHeight);
620 |
621 | // Add into target table wrap
622 | this.$scrollBarWrap.append($scrollBarContainer);
623 | this.$tableWrapper.append(this.$scrollBarWrap);
624 |
625 | /**
626 | * Listener - Freeze scroll bar effected Table
627 | */
628 | this.$scrollBarWrap.on('scroll.'+this.namespace, function() {
629 |
630 | that.$tableWrapper.scrollLeft($(this).scrollLeft());
631 | });
632 |
633 | /**
634 | * Listener - Table scroll for effecting Freeze scroll bar
635 | */
636 | this.$tableWrapper.on('scroll.'+this.namespace, function() {
637 |
638 | // this.$headTableWrap.css('left', $table.offset().left);
639 | that.$scrollBarWrap.scrollLeft($(this).scrollLeft());
640 | });
641 |
642 | /**
643 | * Listener - Window scroll for effecting scroll bar
644 | */
645 | this.$container.on('scroll.'+this.namespace, function() {
646 |
647 | // Current container's top position
648 | var bottomPosition = that.$container.scrollTop() + that.$container.height() - theadHeight + that.fixedNavbarHeight;
649 |
650 | // Detect Current container's top is in the table scope
651 | if (that.$table.offset().top - 1 <= bottomPosition && (that.$table.offset().top + that.$table.outerHeight() - 1) >= bottomPosition) {
652 |
653 | that.$scrollBarWrap.css('visibility', 'visible');
654 |
655 | } else {
656 |
657 | that.$scrollBarWrap.css('visibility', 'hidden');
658 | }
659 | });
660 |
661 | /**
662 | * Listener - Window resize for effecting scroll bar
663 | */
664 | this.$container.on('resize.'+this.namespace, function() {
665 |
666 | // Update width
667 | $scrollBarContainer.css('width', that.$table.width())
668 | // Update Wrap
669 | that.$scrollBarWrap.css('width', that.$tableWrapper.width());
670 | });
671 | }
672 |
673 | /**
674 | * Clone element
675 | *
676 | * @param {element} element
677 | */
678 | FreezeTable.prototype.clone = function (element) {
679 |
680 | var $clone = $(element).clone()
681 | .removeAttr('id') // Remove ID
682 |
683 | // Bootstrap background-color transparent problem
684 | if (this.backgroundColor) {
685 | $clone.css('background-color', this.backgroundColor);
686 | }
687 |
688 | return $clone;
689 | }
690 |
691 | /**
692 | * simplify cloned head table
693 | *
694 | * @param {element} table Table element
695 | */
696 | FreezeTable.prototype.simplifyHead = function (table) {
697 |
698 | var that = this;
699 |
700 | var $headTable = $(table);
701 | // Remove non-display DOM but keeping first row for accuracy
702 | $headTable.find("> tr, > tbody > tr, tfoot > tr").not(':first').remove();
703 | // Each th/td width synchronism
704 | $.each($headTable.find("> thead > tr:nth-child(1) >"), function (key, value) {
705 |
706 | var width = that.$table.find("> thead > tr:nth-child(1) > :nth-child("+parseInt(key+1)+")").outerWidth();
707 | $(this).css('width', width);
708 | });
709 |
710 | return $headTable;
711 | }
712 |
713 | /**
714 | * Detect is already initialized
715 | */
716 | FreezeTable.prototype.isInit = function() {
717 |
718 | // Check existence DOM
719 | if (this.$tableWrapper.find("."+this.headWrapClass).length)
720 | return true;
721 | if (this.$tableWrapper.find("."+this.columnWrapClass).length)
722 | return true;
723 | if (this.$tableWrapper.find("."+this.columnHeadWrapClass).length)
724 | return true;
725 | if (this.$tableWrapper.find("."+this.scrollBarWrapClass).length)
726 | return true;
727 |
728 | return false;
729 |
730 | }
731 |
732 | /**
733 | * Unbind all events by same namespace
734 | */
735 | FreezeTable.prototype.unbind = function() {
736 |
737 | this.$container.off('resize.'+this.namespace);
738 | this.$container.off('scroll.'+this.namespace);
739 | this.$tableWrapper.off('scroll.'+this.namespace);
740 | }
741 |
742 | /**
743 | * Destroy Freeze Table by same namespace
744 | */
745 | FreezeTable.prototype.destroy = function() {
746 |
747 | this.unbind();
748 | this.$tableWrapper.find("."+this.headWrapClass).remove();
749 | this.$tableWrapper.find("."+this.columnWrapClass).remove();
750 | this.$tableWrapper.find("."+this.columnHeadWrapClass).remove();
751 | this.$tableWrapper.find("."+this.scrollBarWrapClass).remove();
752 | }
753 |
754 | /**
755 | * Resize trigger for current same namespace
756 | */
757 | FreezeTable.prototype.resize = function() {
758 |
759 | this.$container.trigger('resize.'+this.namespace);
760 | this.$container.trigger('scroll.'+this.namespace);
761 | this.$tableWrapper.trigger('scroll.'+this.namespace);
762 |
763 | return true;
764 | }
765 |
766 | /**
767 | * Update for Dynamic Content
768 | */
769 | FreezeTable.prototype.update = function() {
770 |
771 | // Same as re-new object
772 | this.options = 'update';
773 | this.init();
774 | return this;
775 | }
776 |
777 | /**
778 | * Interface
779 | */
780 | // Class for single element
781 | window.FreezeTable = FreezeTable;
782 | // jQuery interface
783 | $.fn.freezeTable = function (options) {
784 |
785 | // Single/Multiple mode
786 | if (this.length === 1) {
787 |
788 | return new FreezeTable(this, options)
789 | }
790 | else if (this.length > 1) {
791 |
792 | var result = [];
793 | // Multiple elements bundle
794 | this.each(function () {
795 | result.push(new FreezeTable(this, options));
796 | });
797 |
798 | return result;
799 | }
800 |
801 | return false;
802 | }
803 |
804 | })(jQuery, window);
805 |
--------------------------------------------------------------------------------
/docs/dist/js/freeze-table.js:
--------------------------------------------------------------------------------
1 | /**
2 | * RWD Table with freezing head and columns for jQuery
3 | *
4 | * @author Nick Tsai
5 | * @version 1.3.0
6 | * @see https://github.com/yidas/jquery-freeze-table
7 | */
8 | (function ($, window) {
9 |
10 | 'use strict';
11 |
12 | /**
13 | * Main object
14 | *
15 | * @param {element} element
16 | * @param {object} options
17 | */
18 | var FreezeTable = function(element, options) {
19 |
20 | // Target element initialization
21 | this.$tableWrapper = $(element).first();
22 |
23 | // Options
24 | this.options = options || {};
25 | this.namespace = this.options.namespace || 'freeze-table';
26 | this.callback;
27 | this.scrollBarHeight;
28 | this.shadow;
29 | this.fastMode;
30 | this.backgroundColor;
31 | this.scrollable;
32 |
33 | // Caches
34 | this.$table = this.$tableWrapper.children("table");
35 | this.$container = ((typeof this.options.container !== 'undefined') && this.options.container && $(this.options.container).length) ? $(this.options.container) : $(window);
36 | this.$headTableWrap;
37 | this.$columnTableWrap;
38 | this.$columnHeadTableWrap;
39 | this.$scrollBarWrap;
40 | this.fixedNavbarHeight;
41 | this.isWindowScrollX = false;
42 |
43 | // Static class names for clone wraps
44 | this.headWrapClass = 'clone-head-table-wrap';
45 | this.columnWrapClass = 'clone-column-table-wrap';
46 | this.columnHeadWrapClass = 'clone-column-head-table-wrap';
47 | this.scrollBarWrapClass = 'clone-scroll-bar-wrap';
48 |
49 | this.init();
50 |
51 | return this;
52 | }
53 |
54 | /**
55 | * Initialization
56 | */
57 | FreezeTable.prototype.init = function() {
58 |
59 | // Element check
60 | if (!this.$table.length) {
61 | throw "The element must contain a table dom";
62 | }
63 |
64 | /**
65 | * Update Mode
66 | */
67 | if (this.options==='update') {
68 |
69 | this.destroy();
70 | this.options = this.$tableWrapper.data('freeze-table-data');
71 | }
72 | else if (this.options==='resize') {
73 |
74 | this.options = this.$tableWrapper.data('freeze-table-data');
75 | // Get selected FreezeTable's namespace
76 | this.namespace = this.options.namespace || this.namespace;
77 | this.resize();
78 | // Skip init for better performance usage
79 | return;
80 | }
81 | else {
82 | // Save to DOM data
83 | this.$tableWrapper.data('freeze-table-data', this.options);
84 | }
85 |
86 | /**
87 | * Options Setting
88 | */
89 | var options = this.options;
90 | var freezeHead = (typeof options.freezeHead !== 'undefined') ? options.freezeHead : true;
91 | var freezeColumn = (typeof options.freezeColumn !== 'undefined') ? options.freezeColumn : true;
92 | var freezeColumnHead = (typeof options.freezeColumnHead !== 'undefined') ? options.freezeColumnHead : true;
93 | var scrollBar = (typeof options.scrollBar !== 'undefined') ? options.scrollBar : false;
94 | var fixedNavbar = options.fixedNavbar || '.navbar-fixed-top';
95 | var callback = options.callback || null;
96 | this.namespace = this.options.namespace || this.namespace;
97 | // Default to get window scroll bar height
98 | this.scrollBarHeight = ($.isNumeric(options.scrollBarHeight)) ? options.scrollBarHeight : (window.innerWidth - document.documentElement.clientWidth);
99 | this.shadow = (typeof options.shadow !== 'undefined') ? options.shadow : false;
100 | this.fastMode = (typeof options.fastMode !== 'undefined') ? options.fastMode : false;
101 | this.backgroundColor = (typeof options.backgroundColor !== 'undefined') ? options.backgroundColor : 'white';
102 | this.scrollable = (typeof options.scrollable !== 'undefined') ? options.scrollable : false;
103 |
104 | // Get navbar height for keeping fixed navbar
105 | this.fixedNavbarHeight = (fixedNavbar) ? $(fixedNavbar).outerHeight() || 0 : 0;
106 |
107 | // Check existence
108 | if (this.isInit()) {
109 | this.destroy();
110 | }
111 |
112 | // Release height of the table wrapper
113 | if (!this.scrollable) {
114 | this.$tableWrapper.css('height', '100%')
115 | .css('min-height', '100%')
116 | .css('max-height', '100%');
117 | }
118 |
119 | /**
120 | * Building
121 | */
122 | // Switch for freezeHead
123 | if (freezeHead) {
124 | this.buildHeadTable();
125 | }
126 | // Switch for freezeColumn
127 | if (freezeColumn) {
128 | this.buildColumnTable();
129 | // X scroll bar
130 | this.$tableWrapper.css('overflow-x', 'scroll');
131 | }
132 | // Switch for freezeColumnHead
133 | if (freezeColumnHead && freezeHead && freezeColumn) {
134 | this.buildColumnHeadTable();
135 | }
136 | // Switch for scrollBar
137 | if (scrollBar) {
138 | this.buildScrollBar();
139 | }
140 |
141 | // Body scroll-x prevention
142 | var detectWindowScroll = (function (){
143 | // If body scroll-x is opened, close library to prevent Invalid usage
144 | if (this.$container.scrollLeft() > 0) {
145 | // Mark
146 | this.isWindowScrollX = true;
147 | // Hide all components
148 | if (this.$headTableWrap) {
149 | this.$headTableWrap.css('visibility', 'hidden');
150 | }
151 | if (this.$columnTableWrap) {
152 | this.$columnTableWrap.css('visibility', 'hidden');
153 | }
154 | if (this.$columnHeadTableWrap) {
155 | this.$columnHeadTableWrap.css('visibility', 'hidden');
156 | }
157 | if (this.$scrollBarWrap) {
158 | this.$scrollBarWrap.css('visibility', 'hidden');
159 | }
160 |
161 | } else {
162 | // Unmark
163 | this.isWindowScrollX = false;
164 | }
165 |
166 | }).bind(this);
167 | // Listener of Body scroll-x prevention
168 | this.$container.on('scroll.'+this.namespace, function () {
169 |
170 | detectWindowScroll();
171 | });
172 |
173 | // Initialization
174 | this.resize();
175 |
176 | // Callback
177 | if (typeof callback === 'function') {
178 | callback();
179 | }
180 | }
181 |
182 | /**
183 | * Freeze thead table
184 | */
185 | FreezeTable.prototype.buildHeadTable = function() {
186 |
187 | var that = this;
188 |
189 | // Clone the table as Fixed thead
190 | var $headTable = this.clone(this.$table);
191 |
192 | // Fast Mode
193 | if (this.fastMode) {
194 | var $headTable = this.simplifyHead($headTable);
195 | }
196 |
197 | var headWrapStyles = this.options.headWrapStyles || null;
198 | // Wrap the Fixed Column table
199 | this.$headTableWrap = $('')
200 | .append($headTable)
201 | .css('position', 'fixed')
202 | .css('overflow', 'hidden')
203 | .css('visibility', 'hidden')
204 | .css('top', 0 + this.fixedNavbarHeight)
205 | .css('z-index', 2);
206 | // Shadow option
207 | if (this.shadow) {
208 | this.$headTableWrap.css('box-shadow', '0px 6px 10px -5px rgba(159, 159, 160, 0.8)');
209 | }
210 | // Styles option
211 | if (headWrapStyles && typeof headWrapStyles === "object") {
212 | $.each(headWrapStyles, function(key, value) {
213 | that.$headTableWrap.css(key, value);
214 | });
215 | }
216 | // Add into target table wrap
217 | this.$tableWrapper.append(this.$headTableWrap);
218 |
219 | /**
220 | * Listener - Table scroll for effecting Freeze Column
221 | */
222 | this.$tableWrapper.on('scroll.'+this.namespace, function() {
223 |
224 | // this.$headTableWrap.css('left', this.$table.offset().left);
225 | that.$headTableWrap.scrollLeft($(this).scrollLeft());
226 | });
227 |
228 | // Scrollable option
229 | if (this.scrollable) {
230 |
231 | var handler = function (window, that) {
232 |
233 | var top = that.$tableWrapper.offset().top;
234 |
235 | // Detect Current container's top is in the table scope
236 | if (that.$tableWrapper.scrollTop() > 0 && top > that.fixedNavbarHeight) {
237 |
238 | that.$headTableWrap.offset({top: top});
239 | that.$headTableWrap.css('visibility', 'visible');
240 |
241 | } else {
242 |
243 | that.$headTableWrap.css('visibility', 'hidden');
244 | }
245 | }
246 |
247 | /**
248 | * Listener - Window scroll for effecting freeze head table
249 | */
250 | this.$tableWrapper.on('scroll.'+this.namespace, function() {
251 |
252 | handler(window, that);
253 | });
254 |
255 | this.$container.on('scroll.'+this.namespace, function() {
256 |
257 | handler(window, that);
258 | });
259 |
260 | }
261 | // Default with window container
262 | else if ($.isWindow(that.$container.get(0))) {
263 |
264 | /**
265 | * Listener - Window scroll for effecting freeze head table
266 | */
267 | this.$container.on('scroll.'+this.namespace, function() {
268 |
269 | // Current container's top position
270 | var topPosition = that.$container.scrollTop() + that.fixedNavbarHeight;
271 | var tableTop = that.$table.offset().top - 1;
272 |
273 | // Detect Current container's top is in the table scope
274 | if (tableTop - 1 <= topPosition && (tableTop + that.$table.outerHeight() - 1) >= topPosition) {
275 |
276 | that.$headTableWrap.css('visibility', 'visible');
277 |
278 | } else {
279 |
280 | that.$headTableWrap.css('visibility', 'hidden');
281 | }
282 | });
283 | }
284 | // Container setting
285 | else {
286 |
287 | /**
288 | * Listener - Window scroll for effecting freeze head table
289 | */
290 | this.$container.on('scroll.'+this.namespace, function() {
291 |
292 | var windowTop = $(window).scrollTop();
293 | var tableTop = that.$table.offset().top - 1;
294 |
295 | // Detect Current container's top is in the table scope
296 | if (tableTop <= windowTop && (tableTop + that.$table.outerHeight() - 1) >= windowTop) {
297 |
298 | that.$headTableWrap.offset({top: windowTop});
299 | that.$headTableWrap.css('visibility', 'visible');
300 |
301 | } else {
302 |
303 | that.$headTableWrap.css('visibility', 'hidden');
304 | }
305 | });
306 | }
307 |
308 | /**
309 | * Listener - Window resize for effecting freeze head table
310 | */
311 | this.$container.on('resize.'+this.namespace, function() {
312 |
313 | // Scrollable check and prevention
314 | var headTableWrapWidth = (that.scrollable) ? that.$tableWrapper.width() - that.scrollBarHeight : that.$tableWrapper.width();
315 | headTableWrapWidth = (headTableWrapWidth > 0) ? headTableWrapWidth : that.$tableWrapper.width();
316 | that.$headTableWrap.css('width', headTableWrapWidth);
317 | that.$headTableWrap.css('height', that.$table.find("thead").outerHeight());
318 | });
319 | }
320 |
321 | /**
322 | * Freeze column table
323 | */
324 | FreezeTable.prototype.buildColumnTable = function() {
325 |
326 | var that = this;
327 |
328 | /**
329 | * Setting
330 | */
331 | var columnWrapStyles = this.options.columnWrapStyles || null;
332 | var columnNum = this.options.columnNum || 1;
333 | var columnKeep = (typeof this.options.columnKeep !== 'undefined') ? this.options.columnKeep : false;
334 | // Shadow option
335 | var defaultColumnBorderWidth = (this.shadow) ? 0 : 1;
336 | var columnBorderWidth = (typeof this.options.columnBorderWidth !== 'undefined') ? this.options.columnBorderWidth : defaultColumnBorderWidth;
337 |
338 | // Clone the table as Fixed Column table
339 | var $columnTable = this.clone(this.$table);
340 |
341 | // Wrap the Fixed Column table
342 | this.$columnTableWrap = $('')
343 | .append($columnTable)
344 | .css('position', 'fixed')
345 | .css('overflow', 'hidden')
346 | .css('visibility', 'hidden')
347 | .css('z-index', 1);
348 | // Shadow option
349 | if (this.shadow) {
350 | this.$columnTableWrap.css('box-shadow', '6px 0px 10px -5px rgba(159, 159, 160, 0.8)');
351 | }
352 | // Styles option
353 | if (columnWrapStyles && typeof columnWrapStyles === "object") {
354 | $.each(columnWrapStyles, function(key, value) {
355 | that.$columnTableWrap.css(key, value);
356 | });
357 | }
358 | // Scrollable
359 | if (this.scrollable) {
360 | // Scrollable check and prevention
361 | var columnTableWrapHeight = this.$tableWrapper.height() - this.scrollBarHeight;
362 | columnTableWrapHeight = (columnTableWrapHeight > 0) ? columnTableWrapHeight : this.$tableWrapper.height();
363 | this.$columnTableWrap.height(columnTableWrapHeight);
364 | }
365 | // Add into target table wrap
366 | this.$tableWrapper.append(this.$columnTableWrap);
367 |
368 | /**
369 | * localize the column wrap to current top
370 | */
371 | var localizeWrap = function () {
372 |
373 | that.$columnTableWrap.offset({top: that.$tableWrapper.offset().top});
374 | }
375 |
376 | // Column keep option
377 | if (columnKeep) {
378 |
379 | this.$columnTableWrap.css('visibility', 'visible');
380 |
381 | } else {
382 |
383 | // Scrollable option
384 | if (that.scrollable) {
385 |
386 | /**
387 | * Listener - Table scroll for effecting Freeze Column
388 | */
389 | this.$tableWrapper.on('scroll.'+this.namespace, function() {
390 |
391 |
392 | // Detect for horizontal scroll
393 | if ($(this).scrollLeft() > 0) {
394 |
395 | // Scrollable localization
396 | that.$columnTableWrap.scrollTop(that.$tableWrapper.scrollTop());
397 | that.$columnTableWrap.css('visibility', 'visible');
398 |
399 | } else {
400 |
401 | that.$columnTableWrap.css('visibility', 'hidden');
402 | }
403 | });
404 |
405 | } else {
406 |
407 | /**
408 | * Listener - Table scroll for effecting Freeze Column
409 | */
410 | this.$tableWrapper.on('scroll.'+this.namespace, function() {
411 |
412 | // Disable while isWindowScrollX
413 | if (that.isWindowScrollX)
414 | return;
415 |
416 | // Detect for horizontal scroll
417 | if ($(this).scrollLeft() > 0) {
418 |
419 | that.$columnTableWrap.css('visibility', 'visible');
420 |
421 | } else {
422 |
423 | that.$columnTableWrap.css('visibility', 'hidden');
424 | }
425 | });
426 | }
427 | }
428 |
429 | /**
430 | * Listener - Window resize for effecting tables
431 | */
432 | this.$container.on('resize.'+this.namespace, function() {
433 |
434 | // Follows origin table's width
435 | $columnTable.width(that.$table.width());
436 |
437 | /**
438 | * Dynamic column calculation
439 | */
440 | // Get width by fixed column with number setting
441 | var width = 0 + columnBorderWidth;
442 | for (var i = 1; i <= columnNum; i++) {
443 | // th/td detection
444 | var th = that.$table.find('th:nth-child('+i+')').outerWidth();
445 | var addWidth = (th > 0) ? th : that.$table.find('td:nth-child('+i+')').outerWidth();
446 | width += addWidth;
447 | }
448 | that.$columnTableWrap.width(width);
449 |
450 | localizeWrap();
451 | });
452 |
453 | /**
454 | * Listener - Window scroll for effecting freeze column table
455 | */
456 | this.$container.on('scroll.'+this.namespace, function() {
457 |
458 | localizeWrap();
459 | });
460 | }
461 |
462 | /**
463 | * Freeze column thead table
464 | */
465 | FreezeTable.prototype.buildColumnHeadTable = function() {
466 |
467 | var that = this;
468 |
469 | // Clone head table wrap
470 | this.$columnHeadTableWrap = this.clone(this.$headTableWrap);
471 |
472 | // Fast Mode
473 | if (this.fastMode) {
474 | this.$columnHeadTableWrap = this.simplifyHead(this.$columnHeadTableWrap);
475 | }
476 |
477 | var columnHeadWrapStyles = this.options.columnHeadWrapStyles || null;
478 |
479 | this.$columnHeadTableWrap.removeClass(this.namespace)
480 | .addClass(this.columnHeadWrapClass)
481 | .css('z-index', 3);
482 | // Shadow option
483 | if (this.shadow) {
484 | this.$columnHeadTableWrap.css('box-shadow', 'none');
485 | }
486 | // Styles option
487 | if (columnHeadWrapStyles && typeof columnHeadWrapStyles === "object") {
488 | $.each(columnHeadWrapStyles, function(key, value) {
489 | this.$columnHeadTableWrap.css(key, value);
490 | });
491 | }
492 |
493 | // Add into target table wrap
494 | this.$tableWrapper.append(this.$columnHeadTableWrap);
495 |
496 | // Scrollable option
497 | if (this.scrollable) {
498 |
499 | var detect = function () {
500 |
501 | var top = that.$tableWrapper.offset().top;
502 |
503 | // Detect Current container's top is in the table scope
504 | if (that.$tableWrapper.scrollTop() > 0 && top > that.fixedNavbarHeight) {
505 |
506 | that.$columnHeadTableWrap.offset({top: top});
507 | that.$columnHeadTableWrap.css('visibility', 'visible');
508 |
509 | } else {
510 |
511 | that.$columnHeadTableWrap.css('visibility', 'hidden');
512 | }
513 | }
514 |
515 | /**
516 | * Listener - Window scroll for effecting freeze head table
517 | */
518 | $(this.$tableWrapper).on('scroll.'+this.namespace, function() {
519 |
520 | detect();
521 | });
522 |
523 | }
524 | // Default with window container
525 | else if ($.isWindow(this.$container.get(0))) {
526 |
527 | var detect = function () {
528 |
529 | // Current container's top position
530 | var topPosition = that.$container.scrollTop() + that.fixedNavbarHeight;
531 | var tableTop = that.$table.offset().top - 1;
532 |
533 | // Detect Current container's top is in the table scope
534 | if (tableTop - 1 <= topPosition && (tableTop + that.$table.outerHeight() - 1) >= topPosition && that.$tableWrapper.scrollLeft() > 0) {
535 |
536 | that.$columnHeadTableWrap.css('visibility', 'visible');
537 |
538 | } else {
539 |
540 | that.$columnHeadTableWrap.css('visibility', 'hidden');
541 | }
542 | }
543 | }
544 | // Container setting
545 | else {
546 |
547 | var detect = function () {
548 |
549 | var windowTop = $(window).scrollTop();
550 | var tableTop = that.$table.offset().top - 1;
551 |
552 | // Detect Current container's top is in the table scope
553 | if (tableTop <= windowTop && (tableTop + that.$table.outerHeight() - 1) >= windowTop && that.$tableWrapper.scrollLeft() > 0) {
554 |
555 | that.$columnHeadTableWrap.offset({top: windowTop});
556 | that.$columnHeadTableWrap.css('visibility', 'visible');
557 |
558 | } else {
559 |
560 | that.$columnHeadTableWrap.css('visibility', 'hidden');
561 | }
562 | }
563 | }
564 |
565 | /**
566 | * Listener - Window scroll for effecting Freeze column-head table
567 | */
568 | this.$container.on('scroll.'+this.namespace, function() {
569 |
570 | detect();
571 | });
572 |
573 | /**
574 | * Listener - Table scroll for effecting Freeze column-head table
575 | */
576 | this.$tableWrapper.on('scroll.'+this.namespace, function() {
577 |
578 | // Disable while isWindowScrollX
579 | if (that.isWindowScrollX)
580 | return;
581 |
582 | detect();
583 | });
584 |
585 | /**
586 | * Listener - Window resize for effecting freeze column-head table
587 | */
588 | this.$container.on('resize.'+this.namespace, function() {
589 |
590 | // Table synchronism
591 | that.$columnHeadTableWrap.find("> table").css('width', that.$table.width());
592 | that.$columnHeadTableWrap.css('width', that.$columnTableWrap.width());
593 | that.$columnHeadTableWrap.css('height', that.$table.find("thead").outerHeight());
594 | });
595 | }
596 |
597 | /**
598 | * Freeze scroll bar
599 | */
600 | FreezeTable.prototype.buildScrollBar = function() {
601 |
602 | var that = this;
603 |
604 | var theadHeight = this.$table.find("thead").outerHeight();
605 |
606 | // Scroll wrap container
607 | var $scrollBarContainer = $('')
608 | .css('width', this.$table.width())
609 | .css('height', 1);
610 |
611 | // Wrap the Fixed Column table
612 | this.$scrollBarWrap = $('')
613 | .css('position', 'fixed')
614 | .css('overflow-x', 'scroll')
615 | .css('visibility', 'hidden')
616 | .css('bottom', 0)
617 | .css('z-index', 2)
618 | .css('width', this.$tableWrapper.width())
619 | .css('height', this.scrollBarHeight);
620 |
621 | // Add into target table wrap
622 | this.$scrollBarWrap.append($scrollBarContainer);
623 | this.$tableWrapper.append(this.$scrollBarWrap);
624 |
625 | /**
626 | * Listener - Freeze scroll bar effected Table
627 | */
628 | this.$scrollBarWrap.on('scroll.'+this.namespace, function() {
629 |
630 | that.$tableWrapper.scrollLeft($(this).scrollLeft());
631 | });
632 |
633 | /**
634 | * Listener - Table scroll for effecting Freeze scroll bar
635 | */
636 | this.$tableWrapper.on('scroll.'+this.namespace, function() {
637 |
638 | // this.$headTableWrap.css('left', $table.offset().left);
639 | that.$scrollBarWrap.scrollLeft($(this).scrollLeft());
640 | });
641 |
642 | /**
643 | * Listener - Window scroll for effecting scroll bar
644 | */
645 | this.$container.on('scroll.'+this.namespace, function() {
646 |
647 | // Current container's top position
648 | var bottomPosition = that.$container.scrollTop() + that.$container.height() - theadHeight + that.fixedNavbarHeight;
649 |
650 | // Detect Current container's top is in the table scope
651 | if (that.$table.offset().top - 1 <= bottomPosition && (that.$table.offset().top + that.$table.outerHeight() - 1) >= bottomPosition) {
652 |
653 | that.$scrollBarWrap.css('visibility', 'visible');
654 |
655 | } else {
656 |
657 | that.$scrollBarWrap.css('visibility', 'hidden');
658 | }
659 | });
660 |
661 | /**
662 | * Listener - Window resize for effecting scroll bar
663 | */
664 | this.$container.on('resize.'+this.namespace, function() {
665 |
666 | // Update width
667 | $scrollBarContainer.css('width', that.$table.width())
668 | // Update Wrap
669 | that.$scrollBarWrap.css('width', that.$tableWrapper.width());
670 | });
671 | }
672 |
673 | /**
674 | * Clone element
675 | *
676 | * @param {element} element
677 | */
678 | FreezeTable.prototype.clone = function (element) {
679 |
680 | var $clone = $(element).clone()
681 | .removeAttr('id') // Remove ID
682 |
683 | // Bootstrap background-color transparent problem
684 | if (this.backgroundColor) {
685 | $clone.css('background-color', this.backgroundColor);
686 | }
687 |
688 | return $clone;
689 | }
690 |
691 | /**
692 | * simplify cloned head table
693 | *
694 | * @param {element} table Table element
695 | */
696 | FreezeTable.prototype.simplifyHead = function (table) {
697 |
698 | var that = this;
699 |
700 | var $headTable = $(table);
701 | // Remove non-display DOM but keeping first row for accuracy
702 | $headTable.find("> tr, > tbody > tr, tfoot > tr").not(':first').remove();
703 | // Each th/td width synchronism
704 | $.each($headTable.find("> thead > tr:nth-child(1) >"), function (key, value) {
705 |
706 | var width = that.$table.find("> thead > tr:nth-child(1) > :nth-child("+parseInt(key+1)+")").outerWidth();
707 | $(this).css('width', width);
708 | });
709 |
710 | return $headTable;
711 | }
712 |
713 | /**
714 | * Detect is already initialized
715 | */
716 | FreezeTable.prototype.isInit = function() {
717 |
718 | // Check existence DOM
719 | if (this.$tableWrapper.find("."+this.headWrapClass).length)
720 | return true;
721 | if (this.$tableWrapper.find("."+this.columnWrapClass).length)
722 | return true;
723 | if (this.$tableWrapper.find("."+this.columnHeadWrapClass).length)
724 | return true;
725 | if (this.$tableWrapper.find("."+this.scrollBarWrapClass).length)
726 | return true;
727 |
728 | return false;
729 |
730 | }
731 |
732 | /**
733 | * Unbind all events by same namespace
734 | */
735 | FreezeTable.prototype.unbind = function() {
736 |
737 | this.$container.off('resize.'+this.namespace);
738 | this.$container.off('scroll.'+this.namespace);
739 | this.$tableWrapper.off('scroll.'+this.namespace);
740 | }
741 |
742 | /**
743 | * Destroy Freeze Table by same namespace
744 | */
745 | FreezeTable.prototype.destroy = function() {
746 |
747 | this.unbind();
748 | this.$tableWrapper.find("."+this.headWrapClass).remove();
749 | this.$tableWrapper.find("."+this.columnWrapClass).remove();
750 | this.$tableWrapper.find("."+this.columnHeadWrapClass).remove();
751 | this.$tableWrapper.find("."+this.scrollBarWrapClass).remove();
752 | }
753 |
754 | /**
755 | * Resize trigger for current same namespace
756 | */
757 | FreezeTable.prototype.resize = function() {
758 |
759 | this.$container.trigger('resize.'+this.namespace);
760 | this.$container.trigger('scroll.'+this.namespace);
761 | this.$tableWrapper.trigger('scroll.'+this.namespace);
762 |
763 | return true;
764 | }
765 |
766 | /**
767 | * Update for Dynamic Content
768 | */
769 | FreezeTable.prototype.update = function() {
770 |
771 | // Same as re-new object
772 | this.options = 'update';
773 | this.init();
774 | return this;
775 | }
776 |
777 | /**
778 | * Interface
779 | */
780 | // Class for single element
781 | window.FreezeTable = FreezeTable;
782 | // jQuery interface
783 | $.fn.freezeTable = function (options) {
784 |
785 | // Single/Multiple mode
786 | if (this.length === 1) {
787 |
788 | return new FreezeTable(this, options)
789 | }
790 | else if (this.length > 1) {
791 |
792 | var result = [];
793 | // Multiple elements bundle
794 | this.each(function () {
795 | result.push(new FreezeTable(this, options));
796 | });
797 |
798 | return result;
799 | }
800 |
801 | return false;
802 | }
803 |
804 | })(jQuery, window);
805 |
--------------------------------------------------------------------------------
/docs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | yidas/jquery-freeze-table Demo
7 |
8 |
9 |
10 |
11 |
12 |
13 |
22 |
23 |
24 |
25 |
26 |
39 |
40 |
41 |
42 |
43 |
44 | | Company |
45 | Last Trade |
46 | Trade Time |
47 | Change |
48 | Prev Close |
49 | Open |
50 | Bid |
51 | Ask |
52 | 1y Target Est |
53 | Lorem |
54 | Ipsum |
55 |
56 |
57 |
58 |
59 | | GOOG Google Inc. |
60 | 597.74 |
61 | 12:12PM |
62 | 14.81 (2.54%) |
63 | 582.93 |
64 | 597.95 |
65 | 597.73 x 100 |
66 | 597.91 x 300 |
67 | 731.10 |
68 | Spanning cell |
69 |
70 |
71 | | AAPL Apple Inc. |
72 | 378.94 |
73 | 12:22PM |
74 | 5.74 (1.54%) |
75 | 373.20 |
76 | 381.02 |
77 | 378.92 x 300 |
78 | 378.99 x 100 |
79 | 505.94 |
80 | Spanning cell |
81 |
82 |
83 | | AMZN Amazon.com Inc. |
84 | 191.55 |
85 | 12:23PM |
86 | 3.16 (1.68%) |
87 | 188.39 |
88 | 194.99 |
89 | 191.52 x 300 |
90 | 191.58 x 100 |
91 | 240.32 |
92 | Spanning cell |
93 |
94 |
95 | | ORCL Oracle Corporation |
96 | 31.15 |
97 | 12:44PM |
98 | 1.41 (4.72%) |
99 | 29.74 |
100 | 30.67 |
101 | 31.14 x 6500 |
102 | 31.15 x 3200 |
103 | 36.11 |
104 | Spanning cell |
105 |
106 |
107 | | MSFT Microsoft Corporation |
108 | 25.50 |
109 | 12:27PM |
110 | 0.66 (2.67%) |
111 | 24.84 |
112 | 25.37 |
113 | 25.50 x 71100 |
114 | 25.51 x 17800 |
115 | 31.50 |
116 | Non-spanning |
117 | Non-spanning |
118 |
119 |
120 | | CSCO Cisco Systems, Inc. |
121 | 18.65 |
122 | 12:45PM |
123 | 0.97 (5.49%) |
124 | 17.68 |
125 | 18.23 |
126 | 18.65 x 10300 |
127 | 18.66 x 24000 |
128 | 21.12 |
129 | Non-spanning |
130 | Non-spanning |
131 |
132 |
133 | | YHOO Yahoo! Inc. |
134 | 15.81 |
135 | 12:25PM |
136 | 0.11 (0.67%) |
137 | 15.70 |
138 | 15.94 |
139 | 15.79 x 6100 |
140 | 15.80 x 17000 |
141 | 18.16 |
142 | Non-spanning |
143 | Non-spanning |
144 |
145 |
146 |
147 | | GOOG Google Inc. |
148 | 597.74 |
149 | 12:12PM |
150 | 14.81 (2.54%) |
151 | 582.93 |
152 | 597.95 |
153 | 597.73 x 100 |
154 | 597.91 x 300 |
155 | 731.10 |
156 | Spanning cell |
157 |
158 |
159 | | AAPL Apple Inc. |
160 | 378.94 |
161 | 12:22PM |
162 | 5.74 (1.54%) |
163 | 373.20 |
164 | 381.02 |
165 | 378.92 x 300 |
166 | 378.99 x 100 |
167 | 505.94 |
168 | Spanning cell |
169 |
170 |
171 | | AMZN Amazon.com Inc. |
172 | 191.55 |
173 | 12:23PM |
174 | 3.16 (1.68%) |
175 | 188.39 |
176 | 194.99 |
177 | 191.52 x 300 |
178 | 191.58 x 100 |
179 | 240.32 |
180 | Spanning cell |
181 |
182 |
183 | | ORCL Oracle Corporation |
184 | 31.15 |
185 | 12:44PM |
186 | 1.41 (4.72%) |
187 | 29.74 |
188 | 30.67 |
189 | 31.14 x 6500 |
190 | 31.15 x 3200 |
191 | 36.11 |
192 | Spanning cell |
193 |
194 |
195 | | MSFT Microsoft Corporation |
196 | 25.50 |
197 | 12:27PM |
198 | 0.66 (2.67%) |
199 | 24.84 |
200 | 25.37 |
201 | 25.50 x 71100 |
202 | 25.51 x 17800 |
203 | 31.50 |
204 | Non-spanning |
205 | Non-spanning |
206 |
207 |
208 | | CSCO Cisco Systems, Inc. |
209 | 18.65 |
210 | 12:45PM |
211 | 0.97 (5.49%) |
212 | 17.68 |
213 | 18.23 |
214 | 18.65 x 10300 |
215 | 18.66 x 24000 |
216 | 21.12 |
217 | Non-spanning |
218 | Non-spanning |
219 |
220 |
221 | | YHOO Yahoo! Inc. |
222 | 15.81 |
223 | 12:25PM |
224 | 0.11 (0.67%) |
225 | 15.70 |
226 | 15.94 |
227 | 15.79 x 6100 |
228 | 15.80 x 17000 |
229 | 18.16 |
230 | Non-spanning |
231 | Non-spanning |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
$(".table-basic").freezeTable();
243 |
244 |
245 |
246 |
247 |
248 |
249 |
Scrollable Table
250 |
251 |
447 |
448 |
449 |
450 |
451 |
452 |
453 |
$(".table-scrollable").freezeTable({
454 | 'scrollable': true,
455 | });
456 |
457 |
458 |
459 |
460 |
461 |
462 |
Table in Bootstrap Modal
463 |
464 |
The freezeHead may has the transparent problem with some browser.
465 |
466 |
467 |
468 |
471 |
472 |
473 |
474 |
475 |
476 |
477 |
478 |
479 |
485 |
486 |
487 |
488 |
489 |
490 |
491 | | Company |
492 | Last Trade |
493 | Trade Time |
494 | Change |
495 | Prev Close |
496 | Open |
497 | Bid |
498 | Ask |
499 | 1y Target Est |
500 | Lorem |
501 | Ipsum |
502 |
503 |
504 |
505 |
506 | | GOOG Google Inc. |
507 | 597.74 |
508 | 12:12PM |
509 | 14.81 (2.54%) |
510 | 582.93 |
511 | 597.95 |
512 | 597.73 x 100 |
513 | 597.91 x 300 |
514 | 731.10 |
515 | Spanning cell |
516 |
517 |
518 | | AAPL Apple Inc. |
519 | 378.94 |
520 | 12:22PM |
521 | 5.74 (1.54%) |
522 | 373.20 |
523 | 381.02 |
524 | 378.92 x 300 |
525 | 378.99 x 100 |
526 | 505.94 |
527 | Spanning cell |
528 |
529 |
530 | | AMZN Amazon.com Inc. |
531 | 191.55 |
532 | 12:23PM |
533 | 3.16 (1.68%) |
534 | 188.39 |
535 | 194.99 |
536 | 191.52 x 300 |
537 | 191.58 x 100 |
538 | 240.32 |
539 | Spanning cell |
540 |
541 |
542 | | ORCL Oracle Corporation |
543 | 31.15 |
544 | 12:44PM |
545 | 1.41 (4.72%) |
546 | 29.74 |
547 | 30.67 |
548 | 31.14 x 6500 |
549 | 31.15 x 3200 |
550 | 36.11 |
551 | Spanning cell |
552 |
553 |
554 | | MSFT Microsoft Corporation |
555 | 25.50 |
556 | 12:27PM |
557 | 0.66 (2.67%) |
558 | 24.84 |
559 | 25.37 |
560 | 25.50 x 71100 |
561 | 25.51 x 17800 |
562 | 31.50 |
563 | Non-spanning |
564 | Non-spanning |
565 |
566 |
567 | | CSCO Cisco Systems, Inc. |
568 | 18.65 |
569 | 12:45PM |
570 | 0.97 (5.49%) |
571 | 17.68 |
572 | 18.23 |
573 | 18.65 x 10300 |
574 | 18.66 x 24000 |
575 | 21.12 |
576 | Non-spanning |
577 | Non-spanning |
578 |
579 |
580 | | YHOO Yahoo! Inc. |
581 | 15.81 |
582 | 12:25PM |
583 | 0.11 (0.67%) |
584 | 15.70 |
585 | 15.94 |
586 | 15.79 x 6100 |
587 | 15.80 x 17000 |
588 | 18.16 |
589 | Non-spanning |
590 | Non-spanning |
591 |
592 |
593 |
594 | | GOOG Google Inc. |
595 | 597.74 |
596 | 12:12PM |
597 | 14.81 (2.54%) |
598 | 582.93 |
599 | 597.95 |
600 | 597.73 x 100 |
601 | 597.91 x 300 |
602 | 731.10 |
603 | Spanning cell |
604 |
605 |
606 | | AAPL Apple Inc. |
607 | 378.94 |
608 | 12:22PM |
609 | 5.74 (1.54%) |
610 | 373.20 |
611 | 381.02 |
612 | 378.92 x 300 |
613 | 378.99 x 100 |
614 | 505.94 |
615 | Spanning cell |
616 |
617 |
618 | | AMZN Amazon.com Inc. |
619 | 191.55 |
620 | 12:23PM |
621 | 3.16 (1.68%) |
622 | 188.39 |
623 | 194.99 |
624 | 191.52 x 300 |
625 | 191.58 x 100 |
626 | 240.32 |
627 | Spanning cell |
628 |
629 |
630 | | ORCL Oracle Corporation |
631 | 31.15 |
632 | 12:44PM |
633 | 1.41 (4.72%) |
634 | 29.74 |
635 | 30.67 |
636 | 31.14 x 6500 |
637 | 31.15 x 3200 |
638 | 36.11 |
639 | Spanning cell |
640 |
641 |
642 | | MSFT Microsoft Corporation |
643 | 25.50 |
644 | 12:27PM |
645 | 0.66 (2.67%) |
646 | 24.84 |
647 | 25.37 |
648 | 25.50 x 71100 |
649 | 25.51 x 17800 |
650 | 31.50 |
651 | Non-spanning |
652 | Non-spanning |
653 |
654 |
655 | | CSCO Cisco Systems, Inc. |
656 | 18.65 |
657 | 12:45PM |
658 | 0.97 (5.49%) |
659 | 17.68 |
660 | 18.23 |
661 | 18.65 x 10300 |
662 | 18.66 x 24000 |
663 | 21.12 |
664 | Non-spanning |
665 | Non-spanning |
666 |
667 |
668 | | YHOO Yahoo! Inc. |
669 | 15.81 |
670 | 12:25PM |
671 | 0.11 (0.67%) |
672 | 15.70 |
673 | 15.94 |
674 | 15.79 x 6100 |
675 | 15.80 x 17000 |
676 | 18.16 |
677 | Non-spanning |
678 | Non-spanning |
679 |
680 |
681 | | GOOG Google Inc. |
682 | 597.74 |
683 | 12:12PM |
684 | 14.81 (2.54%) |
685 | 582.93 |
686 | 597.95 |
687 | 597.73 x 100 |
688 | 597.91 x 300 |
689 | 731.10 |
690 | Spanning cell |
691 |
692 |
693 | | AAPL Apple Inc. |
694 | 378.94 |
695 | 12:22PM |
696 | 5.74 (1.54%) |
697 | 373.20 |
698 | 381.02 |
699 | 378.92 x 300 |
700 | 378.99 x 100 |
701 | 505.94 |
702 | Spanning cell |
703 |
704 |
705 | | AMZN Amazon.com Inc. |
706 | 191.55 |
707 | 12:23PM |
708 | 3.16 (1.68%) |
709 | 188.39 |
710 | 194.99 |
711 | 191.52 x 300 |
712 | 191.58 x 100 |
713 | 240.32 |
714 | Spanning cell |
715 |
716 |
717 | | ORCL Oracle Corporation |
718 | 31.15 |
719 | 12:44PM |
720 | 1.41 (4.72%) |
721 | 29.74 |
722 | 30.67 |
723 | 31.14 x 6500 |
724 | 31.15 x 3200 |
725 | 36.11 |
726 | Spanning cell |
727 |
728 |
729 | | MSFT Microsoft Corporation |
730 | 25.50 |
731 | 12:27PM |
732 | 0.66 (2.67%) |
733 | 24.84 |
734 | 25.37 |
735 | 25.50 x 71100 |
736 | 25.51 x 17800 |
737 | 31.50 |
738 | Non-spanning |
739 | Non-spanning |
740 |
741 |
742 | | CSCO Cisco Systems, Inc. |
743 | 18.65 |
744 | 12:45PM |
745 | 0.97 (5.49%) |
746 | 17.68 |
747 | 18.23 |
748 | 18.65 x 10300 |
749 | 18.66 x 24000 |
750 | 21.12 |
751 | Non-spanning |
752 | Non-spanning |
753 |
754 |
755 | | YHOO Yahoo! Inc. |
756 | 15.81 |
757 | 12:25PM |
758 | 0.11 (0.67%) |
759 | 15.70 |
760 | 15.94 |
761 | 15.79 x 6100 |
762 | 15.80 x 17000 |
763 | 18.16 |
764 | Non-spanning |
765 | Non-spanning |
766 |
767 |
768 |
769 | | GOOG Google Inc. |
770 | 597.74 |
771 | 12:12PM |
772 | 14.81 (2.54%) |
773 | 582.93 |
774 | 597.95 |
775 | 597.73 x 100 |
776 | 597.91 x 300 |
777 | 731.10 |
778 | Spanning cell |
779 |
780 |
781 | | AAPL Apple Inc. |
782 | 378.94 |
783 | 12:22PM |
784 | 5.74 (1.54%) |
785 | 373.20 |
786 | 381.02 |
787 | 378.92 x 300 |
788 | 378.99 x 100 |
789 | 505.94 |
790 | Spanning cell |
791 |
792 |
793 | | AMZN Amazon.com Inc. |
794 | 191.55 |
795 | 12:23PM |
796 | 3.16 (1.68%) |
797 | 188.39 |
798 | 194.99 |
799 | 191.52 x 300 |
800 | 191.58 x 100 |
801 | 240.32 |
802 | Spanning cell |
803 |
804 |
805 | | ORCL Oracle Corporation |
806 | 31.15 |
807 | 12:44PM |
808 | 1.41 (4.72%) |
809 | 29.74 |
810 | 30.67 |
811 | 31.14 x 6500 |
812 | 31.15 x 3200 |
813 | 36.11 |
814 | Spanning cell |
815 |
816 |
817 | | MSFT Microsoft Corporation |
818 | 25.50 |
819 | 12:27PM |
820 | 0.66 (2.67%) |
821 | 24.84 |
822 | 25.37 |
823 | 25.50 x 71100 |
824 | 25.51 x 17800 |
825 | 31.50 |
826 | Non-spanning |
827 | Non-spanning |
828 |
829 |
830 | | CSCO Cisco Systems, Inc. |
831 | 18.65 |
832 | 12:45PM |
833 | 0.97 (5.49%) |
834 | 17.68 |
835 | 18.23 |
836 | 18.65 x 10300 |
837 | 18.66 x 24000 |
838 | 21.12 |
839 | Non-spanning |
840 | Non-spanning |
841 |
842 |
843 | | YHOO Yahoo! Inc. |
844 | 15.81 |
845 | 12:25PM |
846 | 0.11 (0.67%) |
847 | 15.70 |
848 | 15.94 |
849 | 15.79 x 6100 |
850 | 15.80 x 17000 |
851 | 18.16 |
852 | Non-spanning |
853 | Non-spanning |
854 |
855 |
856 |
857 |
858 |
859 |
860 |
864 |
865 |
866 |
867 |
868 |
869 |
870 |
871 |
872 |
873 |
$('#table-modal').one('shown.bs.modal', function (e) {
874 |
875 | $(this).find(".table-modal").freezeTable({
876 | 'container': '#table-modal.modal',
877 | });
878 | });
879 |
880 |
881 |
882 |
883 |
884 |
885 |
Freeze Column(s) only
886 |
887 |
888 |
889 |
890 | | # |
891 | Date |
892 | Text |
893 | Bank (1930) |
894 | Eget kapital John Doe (2010) |
895 | Eget kapital Jane Doe (2020) |
896 | Utgående moms 25 % (2610) |
897 | Moms varuförvärv EU 25 % (2615) |
898 | Ingående moms 25 % (2640) |
899 | Ingående moms utland (2645) |
900 | Moms redovisningskonto (2650) |
901 | Momspliktiga intäkter (3000) |
902 | Inköp varor EU 25 % (4056) |
903 | Förbrukningsinventarier (5400) |
904 | Kontorsmaterial och trycksaker (6100) |
905 | Övriga externa tjänster (6500) |
906 | Bankavgifter (6570) |
907 | Årets resultat (8999) |
908 |
909 |
910 | | Credit |
911 | Debit |
912 | Credit |
913 | Debit |
914 | Credit |
915 | Debit |
916 | Credit |
917 | Debit |
918 | Credit |
919 | Debit |
920 | Credit |
921 | Debit |
922 | Credit |
923 | Debit |
924 | Credit |
925 | Debit |
926 | Credit |
927 | Debit |
928 | Credit |
929 | Debit |
930 | Credit |
931 | Debit |
932 | Credit |
933 | Debit |
934 | Credit |
935 | Debit |
936 | Credit |
937 | Debit |
938 | Credit |
939 | Debit |
940 |
941 |
942 |
943 |
944 | | 1 |
945 | 2014-01-11 |
946 | Office stuff |
947 | 100 SEK |
948 | |
949 | |
950 | |
951 | |
952 | |
953 | |
954 | |
955 | |
956 | |
957 | |
958 | 25 SEK |
959 | |
960 | |
961 | |
962 | |
963 | |
964 | |
965 | |
966 | |
967 | |
968 | |
969 | |
970 | 75 SEK |
971 | |
972 | |
973 | |
974 | |
975 | |
976 | |
977 |
978 |
979 | | 2 |
980 | 2014-02-12 |
981 | iPad |
982 | 5000 SEK |
983 | |
984 | |
985 | |
986 | |
987 | |
988 | |
989 | |
990 | |
991 | |
992 | |
993 | 1250 SEK |
994 | |
995 | |
996 | |
997 | |
998 | |
999 | |
1000 | |
1001 | |
1002 | |
1003 | 3750 SEK |
1004 | |
1005 | |
1006 | |
1007 | |
1008 | |
1009 | |
1010 | |
1011 | |
1012 |
1013 |
1014 | | 3 |
1015 | 2014-03-20 |
1016 | Office stuff |
1017 | 100 SEK |
1018 | |
1019 | |
1020 | |
1021 | |
1022 | |
1023 | |
1024 | |
1025 | |
1026 | |
1027 | |
1028 | 25 SEK |
1029 | |
1030 | |
1031 | |
1032 | |
1033 | |
1034 | |
1035 | |
1036 | |
1037 | |
1038 | |
1039 | |
1040 | 75 SEK |
1041 | |
1042 | |
1043 | |
1044 | |
1045 | |
1046 | |
1047 |
1048 |
1049 | | 4 |
1050 | 2014-04-11 |
1051 | iPhone |
1052 | 7000 SEK |
1053 | |
1054 | |
1055 | |
1056 | |
1057 | |
1058 | |
1059 | |
1060 | |
1061 | |
1062 | |
1063 | 1750 SEK |
1064 | |
1065 | |
1066 | |
1067 | |
1068 | |
1069 | |
1070 | |
1071 | |
1072 | |
1073 | 5250 SEK |
1074 | |
1075 | |
1076 | |
1077 | |
1078 | |
1079 | |
1080 | |
1081 | |
1082 |
1083 |
1084 |
1085 |
1086 | |
1087 | |
1088 | |
1089 | 12 200 SEK |
1090 | |
1091 | |
1092 | |
1093 | |
1094 | |
1095 | |
1096 | |
1097 | |
1098 | |
1099 | |
1100 | 3050 SEK |
1101 | |
1102 | |
1103 | |
1104 | |
1105 | |
1106 | |
1107 | |
1108 | |
1109 | |
1110 | 8000 SEK |
1111 | |
1112 | 150 SEK |
1113 | |
1114 | |
1115 | |
1116 | |
1117 | |
1118 | |
1119 |
1120 |
1121 |
1122 |
1123 |
1124 |
1125 |
1126 |
1127 |
1128 |
$(".table-columns-only").freezeTable({
1129 | 'freezeHead': false,
1130 | });
1131 |
1132 |
1133 |
1134 |
1135 |
1136 |
1137 |
Freeze Head only
1138 |
1139 |
1140 |
1141 |
1142 | | Company |
1143 | Last Trade |
1144 | Trade Time |
1145 | Change |
1146 | Prev Close |
1147 | Open |
1148 | Bid |
1149 | Ask |
1150 | 1y Target Est |
1151 | Lorem |
1152 | Ipsum |
1153 |
1154 |
1155 |
1156 |
1157 | | GOOG Google Inc. |
1158 | 597.74 |
1159 | 12:12PM |
1160 | 14.81 (2.54%) |
1161 | 582.93 |
1162 | 597.95 |
1163 | 597.73 x 100 |
1164 | 597.91 x 300 |
1165 | 731.10 |
1166 | Spanning cell |
1167 |
1168 |
1169 | | AAPL Apple Inc. |
1170 | 378.94 |
1171 | 12:22PM |
1172 | 5.74 (1.54%) |
1173 | 373.20 |
1174 | 381.02 |
1175 | 378.92 x 300 |
1176 | 378.99 x 100 |
1177 | 505.94 |
1178 | Spanning cell |
1179 |
1180 |
1181 | | AMZN Amazon.com Inc. |
1182 | 191.55 |
1183 | 12:23PM |
1184 | 3.16 (1.68%) |
1185 | 188.39 |
1186 | 194.99 |
1187 | 191.52 x 300 |
1188 | 191.58 x 100 |
1189 | 240.32 |
1190 | Spanning cell |
1191 |
1192 |
1193 | | ORCL Oracle Corporation |
1194 | 31.15 |
1195 | 12:44PM |
1196 | 1.41 (4.72%) |
1197 | 29.74 |
1198 | 30.67 |
1199 | 31.14 x 6500 |
1200 | 31.15 x 3200 |
1201 | 36.11 |
1202 | Spanning cell |
1203 |
1204 |
1205 | | MSFT Microsoft Corporation |
1206 | 25.50 |
1207 | 12:27PM |
1208 | 0.66 (2.67%) |
1209 | 24.84 |
1210 | 25.37 |
1211 | 25.50 x 71100 |
1212 | 25.51 x 17800 |
1213 | 31.50 |
1214 | Non-spanning |
1215 | Non-spanning |
1216 |
1217 |
1218 | | CSCO Cisco Systems, Inc. |
1219 | 18.65 |
1220 | 12:45PM |
1221 | 0.97 (5.49%) |
1222 | 17.68 |
1223 | 18.23 |
1224 | 18.65 x 10300 |
1225 | 18.66 x 24000 |
1226 | 21.12 |
1227 | Non-spanning |
1228 | Non-spanning |
1229 |
1230 |
1231 | | YHOO Yahoo! Inc. |
1232 | 15.81 |
1233 | 12:25PM |
1234 | 0.11 (0.67%) |
1235 | 15.70 |
1236 | 15.94 |
1237 | 15.79 x 6100 |
1238 | 15.80 x 17000 |
1239 | 18.16 |
1240 | Non-spanning |
1241 | Non-spanning |
1242 |
1243 |
1244 |
1245 | | GOOG Google Inc. |
1246 | 597.74 |
1247 | 12:12PM |
1248 | 14.81 (2.54%) |
1249 | 582.93 |
1250 | 597.95 |
1251 | 597.73 x 100 |
1252 | 597.91 x 300 |
1253 | 731.10 |
1254 | Spanning cell |
1255 |
1256 |
1257 | | AAPL Apple Inc. |
1258 | 378.94 |
1259 | 12:22PM |
1260 | 5.74 (1.54%) |
1261 | 373.20 |
1262 | 381.02 |
1263 | 378.92 x 300 |
1264 | 378.99 x 100 |
1265 | 505.94 |
1266 | Spanning cell |
1267 |
1268 |
1269 | | AMZN Amazon.com Inc. |
1270 | 191.55 |
1271 | 12:23PM |
1272 | 3.16 (1.68%) |
1273 | 188.39 |
1274 | 194.99 |
1275 | 191.52 x 300 |
1276 | 191.58 x 100 |
1277 | 240.32 |
1278 | Spanning cell |
1279 |
1280 |
1281 | | ORCL Oracle Corporation |
1282 | 31.15 |
1283 | 12:44PM |
1284 | 1.41 (4.72%) |
1285 | 29.74 |
1286 | 30.67 |
1287 | 31.14 x 6500 |
1288 | 31.15 x 3200 |
1289 | 36.11 |
1290 | Spanning cell |
1291 |
1292 |
1293 | | MSFT Microsoft Corporation |
1294 | 25.50 |
1295 | 12:27PM |
1296 | 0.66 (2.67%) |
1297 | 24.84 |
1298 | 25.37 |
1299 | 25.50 x 71100 |
1300 | 25.51 x 17800 |
1301 | 31.50 |
1302 | Non-spanning |
1303 | Non-spanning |
1304 |
1305 |
1306 | | CSCO Cisco Systems, Inc. |
1307 | 18.65 |
1308 | 12:45PM |
1309 | 0.97 (5.49%) |
1310 | 17.68 |
1311 | 18.23 |
1312 | 18.65 x 10300 |
1313 | 18.66 x 24000 |
1314 | 21.12 |
1315 | Non-spanning |
1316 | Non-spanning |
1317 |
1318 |
1319 | | YHOO Yahoo! Inc. |
1320 | 15.81 |
1321 | 12:25PM |
1322 | 0.11 (0.67%) |
1323 | 15.70 |
1324 | 15.94 |
1325 | 15.79 x 6100 |
1326 | 15.80 x 17000 |
1327 | 18.16 |
1328 | Non-spanning |
1329 | Non-spanning |
1330 |
1331 |
1332 |
1333 |
1334 |
1335 |
1336 |
1337 |
1338 |
1339 |
1340 |
$(".table-head-only").freezeTable({
1341 | 'freezeColumn': false,
1342 | });
1343 |
1344 |
1345 |
1346 |
1347 |
1348 |
1349 |
Multi-Columns Freeze Table
1350 |
1351 |
1352 |
1353 |
1354 | | # |
1355 | Date |
1356 | Text |
1357 | Bank (1930) |
1358 | Eget kapital John Doe (2010) |
1359 | Eget kapital Jane Doe (2020) |
1360 | Utgående moms 25 % (2610) |
1361 | Moms varuförvärv EU 25 % (2615) |
1362 | Ingående moms 25 % (2640) |
1363 | Ingående moms utland (2645) |
1364 | Moms redovisningskonto (2650) |
1365 | Momspliktiga intäkter (3000) |
1366 | Inköp varor EU 25 % (4056) |
1367 | Förbrukningsinventarier (5400) |
1368 | Kontorsmaterial och trycksaker (6100) |
1369 | Övriga externa tjänster (6500) |
1370 | Bankavgifter (6570) |
1371 | Årets resultat (8999) |
1372 |
1373 |
1374 | | Credit |
1375 | Debit |
1376 | Credit |
1377 | Debit |
1378 | Credit |
1379 | Debit |
1380 | Credit |
1381 | Debit |
1382 | Credit |
1383 | Debit |
1384 | Credit |
1385 | Debit |
1386 | Credit |
1387 | Debit |
1388 | Credit |
1389 | Debit |
1390 | Credit |
1391 | Debit |
1392 | Credit |
1393 | Debit |
1394 | Credit |
1395 | Debit |
1396 | Credit |
1397 | Debit |
1398 | Credit |
1399 | Debit |
1400 | Credit |
1401 | Debit |
1402 | Credit |
1403 | Debit |
1404 |
1405 |
1406 |
1407 |
1408 | | 1 |
1409 | 2014-01-11 |
1410 | Office stuff |
1411 | 100 SEK |
1412 | |
1413 | |
1414 | |
1415 | |
1416 | |
1417 | |
1418 | |
1419 | |
1420 | |
1421 | |
1422 | 25 SEK |
1423 | |
1424 | |
1425 | |
1426 | |
1427 | |
1428 | |
1429 | |
1430 | |
1431 | |
1432 | |
1433 | |
1434 | 75 SEK |
1435 | |
1436 | |
1437 | |
1438 | |
1439 | |
1440 | |
1441 |
1442 |
1443 | | 2 |
1444 | 2014-02-12 |
1445 | iPad |
1446 | 5000 SEK |
1447 | |
1448 | |
1449 | |
1450 | |
1451 | |
1452 | |
1453 | |
1454 | |
1455 | |
1456 | |
1457 | 1250 SEK |
1458 | |
1459 | |
1460 | |
1461 | |
1462 | |
1463 | |
1464 | |
1465 | |
1466 | |
1467 | 3750 SEK |
1468 | |
1469 | |
1470 | |
1471 | |
1472 | |
1473 | |
1474 | |
1475 | |
1476 |
1477 |
1478 | | 3 |
1479 | 2014-03-20 |
1480 | Office stuff |
1481 | 100 SEK |
1482 | |
1483 | |
1484 | |
1485 | |
1486 | |
1487 | |
1488 | |
1489 | |
1490 | |
1491 | |
1492 | 25 SEK |
1493 | |
1494 | |
1495 | |
1496 | |
1497 | |
1498 | |
1499 | |
1500 | |
1501 | |
1502 | |
1503 | |
1504 | 75 SEK |
1505 | |
1506 | |
1507 | |
1508 | |
1509 | |
1510 | |
1511 |
1512 |
1513 | | 4 |
1514 | 2014-04-11 |
1515 | iPhone |
1516 | 7000 SEK |
1517 | |
1518 | |
1519 | |
1520 | |
1521 | |
1522 | |
1523 | |
1524 | |
1525 | |
1526 | |
1527 | 1750 SEK |
1528 | |
1529 | |
1530 | |
1531 | |
1532 | |
1533 | |
1534 | |
1535 | |
1536 | |
1537 | 5250 SEK |
1538 | |
1539 | |
1540 | |
1541 | |
1542 | |
1543 | |
1544 | |
1545 | |
1546 |
1547 |
1548 |
1549 |
1550 | |
1551 | |
1552 | |
1553 | 12 200 SEK |
1554 | |
1555 | |
1556 | |
1557 | |
1558 | |
1559 | |
1560 | |
1561 | |
1562 | |
1563 | |
1564 | 3050 SEK |
1565 | |
1566 | |
1567 | |
1568 | |
1569 | |
1570 | |
1571 | |
1572 | |
1573 | |
1574 | 8000 SEK |
1575 | |
1576 | 150 SEK |
1577 | |
1578 | |
1579 | |
1580 | |
1581 | |
1582 | |
1583 |
1584 |
1585 |
1586 |
1587 |
1588 |
1589 |
1590 |
1591 |
1592 |
$(".table-multi-columns").freezeTable({
1593 | 'columnNum' : 2,
1594 | });
1595 |
1596 |
1597 |
1598 |
1599 |
1600 |
1601 |
Shadow Enabled Table
1602 |
1603 |
1604 |
1605 |
1606 | | Company |
1607 | Last Trade |
1608 | Trade Time |
1609 | Change |
1610 | Prev Close |
1611 | Open |
1612 | Bid |
1613 | Ask |
1614 | 1y Target Est |
1615 | Lorem |
1616 | Ipsum |
1617 |
1618 |
1619 |
1620 |
1621 | | GOOG Google Inc. |
1622 | 597.74 |
1623 | 12:12PM |
1624 | 14.81 (2.54%) |
1625 | 582.93 |
1626 | 597.95 |
1627 | 597.73 x 100 |
1628 | 597.91 x 300 |
1629 | 731.10 |
1630 | Spanning cell |
1631 |
1632 |
1633 | | AAPL Apple Inc. |
1634 | 378.94 |
1635 | 12:22PM |
1636 | 5.74 (1.54%) |
1637 | 373.20 |
1638 | 381.02 |
1639 | 378.92 x 300 |
1640 | 378.99 x 100 |
1641 | 505.94 |
1642 | Spanning cell |
1643 |
1644 |
1645 | | AMZN Amazon.com Inc. |
1646 | 191.55 |
1647 | 12:23PM |
1648 | 3.16 (1.68%) |
1649 | 188.39 |
1650 | 194.99 |
1651 | 191.52 x 300 |
1652 | 191.58 x 100 |
1653 | 240.32 |
1654 | Spanning cell |
1655 |
1656 |
1657 | | ORCL Oracle Corporation |
1658 | 31.15 |
1659 | 12:44PM |
1660 | 1.41 (4.72%) |
1661 | 29.74 |
1662 | 30.67 |
1663 | 31.14 x 6500 |
1664 | 31.15 x 3200 |
1665 | 36.11 |
1666 | Spanning cell |
1667 |
1668 |
1669 | | MSFT Microsoft Corporation |
1670 | 25.50 |
1671 | 12:27PM |
1672 | 0.66 (2.67%) |
1673 | 24.84 |
1674 | 25.37 |
1675 | 25.50 x 71100 |
1676 | 25.51 x 17800 |
1677 | 31.50 |
1678 | Non-spanning |
1679 | Non-spanning |
1680 |
1681 |
1682 | | CSCO Cisco Systems, Inc. |
1683 | 18.65 |
1684 | 12:45PM |
1685 | 0.97 (5.49%) |
1686 | 17.68 |
1687 | 18.23 |
1688 | 18.65 x 10300 |
1689 | 18.66 x 24000 |
1690 | 21.12 |
1691 | Non-spanning |
1692 | Non-spanning |
1693 |
1694 |
1695 | | YHOO Yahoo! Inc. |
1696 | 15.81 |
1697 | 12:25PM |
1698 | 0.11 (0.67%) |
1699 | 15.70 |
1700 | 15.94 |
1701 | 15.79 x 6100 |
1702 | 15.80 x 17000 |
1703 | 18.16 |
1704 | Non-spanning |
1705 | Non-spanning |
1706 |
1707 |
1708 |
1709 | | GOOG Google Inc. |
1710 | 597.74 |
1711 | 12:12PM |
1712 | 14.81 (2.54%) |
1713 | 582.93 |
1714 | 597.95 |
1715 | 597.73 x 100 |
1716 | 597.91 x 300 |
1717 | 731.10 |
1718 | Spanning cell |
1719 |
1720 |
1721 | | AAPL Apple Inc. |
1722 | 378.94 |
1723 | 12:22PM |
1724 | 5.74 (1.54%) |
1725 | 373.20 |
1726 | 381.02 |
1727 | 378.92 x 300 |
1728 | 378.99 x 100 |
1729 | 505.94 |
1730 | Spanning cell |
1731 |
1732 |
1733 | | AMZN Amazon.com Inc. |
1734 | 191.55 |
1735 | 12:23PM |
1736 | 3.16 (1.68%) |
1737 | 188.39 |
1738 | 194.99 |
1739 | 191.52 x 300 |
1740 | 191.58 x 100 |
1741 | 240.32 |
1742 | Spanning cell |
1743 |
1744 |
1745 | | ORCL Oracle Corporation |
1746 | 31.15 |
1747 | 12:44PM |
1748 | 1.41 (4.72%) |
1749 | 29.74 |
1750 | 30.67 |
1751 | 31.14 x 6500 |
1752 | 31.15 x 3200 |
1753 | 36.11 |
1754 | Spanning cell |
1755 |
1756 |
1757 | | MSFT Microsoft Corporation |
1758 | 25.50 |
1759 | 12:27PM |
1760 | 0.66 (2.67%) |
1761 | 24.84 |
1762 | 25.37 |
1763 | 25.50 x 71100 |
1764 | 25.51 x 17800 |
1765 | 31.50 |
1766 | Non-spanning |
1767 | Non-spanning |
1768 |
1769 |
1770 | | CSCO Cisco Systems, Inc. |
1771 | 18.65 |
1772 | 12:45PM |
1773 | 0.97 (5.49%) |
1774 | 17.68 |
1775 | 18.23 |
1776 | 18.65 x 10300 |
1777 | 18.66 x 24000 |
1778 | 21.12 |
1779 | Non-spanning |
1780 | Non-spanning |
1781 |
1782 |
1783 | | YHOO Yahoo! Inc. |
1784 | 15.81 |
1785 | 12:25PM |
1786 | 0.11 (0.67%) |
1787 | 15.70 |
1788 | 15.94 |
1789 | 15.79 x 6100 |
1790 | 15.80 x 17000 |
1791 | 18.16 |
1792 | Non-spanning |
1793 | Non-spanning |
1794 |
1795 |
1796 |
1797 |
1798 |
1799 |
1800 |
1801 |
1802 |
1803 |
1804 |
$(".table-shadow").freezeTable({
1805 | 'shadow': true,
1806 | });
1807 |
1808 |
1809 |
1810 |
1811 |
1812 |
Customized Styles Table
1813 |
1814 |
1815 |
1816 |
1817 | | # |
1818 | Group A |
1819 | Group B |
1820 | Group C |
1821 | Group D |
1822 | Group E |
1823 | Group F |
1824 | Group G |
1825 | Group H |
1826 | Group I |
1827 |
1828 |
1829 | | # |
1830 | Column A.1 |
1831 | Column A.2 |
1832 | Column B.1 |
1833 | Column B.2 |
1834 | Column C.1 |
1835 | Column C.2 |
1836 | Column D.1 |
1837 | Column D.2 |
1838 | Column E.1 |
1839 | Column E.2 |
1840 | Column F.1 |
1841 | Column F.2 |
1842 | Column G.1 |
1843 | Column G.2 |
1844 | Column H.1 |
1845 | Column H.2 |
1846 | Column I.1 |
1847 | Column I.2 |
1848 |
1849 |
1850 |
1851 |
1852 | | 1 |
1853 | Column A.1 |
1854 | Column A.2 |
1855 | Column B.1 |
1856 | Column B.1 |
1857 | Column C.1 |
1858 | Column C.2 |
1859 | Column D.1 |
1860 | Column D.2 |
1861 | Column E.1 |
1862 | Column E.2 |
1863 | Column F.1 |
1864 | Column F.2 |
1865 | Column G.1 |
1866 | Column G.2 |
1867 | Column H.1 |
1868 | Column H.2 |
1869 | Column I.1 |
1870 | Column I.2 |
1871 |
1872 |
1873 | | 2 |
1874 | Column A |
1875 | Column A |
1876 | Column B |
1877 | Column B |
1878 | Column C |
1879 | Column C |
1880 | Column D |
1881 | Column D |
1882 | Column E |
1883 | Column E |
1884 | Column F |
1885 | Column F |
1886 | Column G |
1887 | Column G |
1888 | Column H |
1889 | Column H |
1890 | Column I |
1891 | Column I |
1892 |
1893 |
1894 | | 3 |
1895 | Column A |
1896 | Column A |
1897 | Column B |
1898 | Column B |
1899 | Column C |
1900 | Column C |
1901 | Column D |
1902 | Column D |
1903 | Column E |
1904 | Column E |
1905 | Column F |
1906 | Column F |
1907 | Column G |
1908 | Column G |
1909 | Column H |
1910 | Column H |
1911 | Column I |
1912 | Column I |
1913 |
1914 |
1915 | | 4 |
1916 | Column A |
1917 | Column A |
1918 | Column B |
1919 | Column B |
1920 | Column C |
1921 | Column C |
1922 | Column D |
1923 | Column D |
1924 | Column E |
1925 | Column E |
1926 | Column F |
1927 | Column F |
1928 | Column G |
1929 | Column G |
1930 | Column H |
1931 | Column H |
1932 | Column I |
1933 | Column I |
1934 |
1935 |
1936 |
1937 |
1938 |
1939 |
1940 |
1941 |
1942 |
1943 |
$(".table-wrap-styles").freezeTable({
1944 | 'headWrapStyles': {'box-shadow': '0px 9px 10px -5px rgba(159, 159, 160, 0.8)'},
1945 | });
1946 |
1947 |
1948 |
1949 |
1950 |
1951 |
1952 |
Freeze Scroll Bar Table (Fixed on the bottom of the screen)
1953 |
2413 |
2414 |
2415 |
2416 |
2417 |
2418 |
$(".table-with-scrollbar").freezeTable({
2419 | 'scrollBar': true,
2420 | });
2421 |
2422 |
2423 |
2424 |
2425 |
2426 |
2427 |
2428 |
Freeze Column(s) Keep
2429 |
Freeze column(s) will always be displayed to support interactive table.
2430 |
2667 |
2668 |
2669 |
2670 |
2671 |
2672 |
$(".table-column-keep").freezeTable({
2673 | 'columnNum': 2,
2674 | 'columnKeep': true,
2675 | });
2676 |
2677 |
2678 |
2679 |
2680 |
2681 |
2684 |
2685 |
2686 |
2687 |
2688 |
2689 |
2690 |
2740 |
2741 |
2742 |
--------------------------------------------------------------------------------