5 <link rel=
"shortcut icon" type=
"image/ico" href=
"http://www.datatables.net/favicon.ico">
6 <meta name=
"viewport" content=
"initial-scale=1.0, maximum-scale=2.0">
8 <title>FixedHeader example - Header, left and right all fixed
</title>
9 <link rel=
"stylesheet" type=
"text/css" href=
"../../../media/css/jquery.dataTables.css">
10 <link rel=
"stylesheet" type=
"text/css" href=
"../css/dataTables.fixedHeader.css">
11 <link rel=
"stylesheet" type=
"text/css" href=
"../../../examples/resources/syntax/shCore.css">
12 <link rel=
"stylesheet" type=
"text/css" href=
"../../../examples/resources/demo.css">
13 <style type=
"text/css" class=
"init">
15 div.dataTables_wrapper {
19 div.FixedHeader_Cloned.fixedLeft tbody td {
20 border-right:
1px solid black;
23 div.FixedHeader_Cloned.fixedRight tbody td {
24 border-left:
1px solid black;
28 <script type=
"text/javascript" language=
"javascript" src=
"../../../media/js/jquery.js"></script>
29 <script type=
"text/javascript" language=
"javascript" src=
"../../../media/js/jquery.dataTables.js"></script>
30 <script type=
"text/javascript" language=
"javascript" src=
"../js/dataTables.fixedHeader.js"></script>
31 <script type=
"text/javascript" language=
"javascript" src=
"../../../examples/resources/syntax/shCore.js"></script>
32 <script type=
"text/javascript" language=
"javascript" src=
"../../../examples/resources/demo.js"></script>
33 <script type=
"text/javascript" language=
"javascript" class=
"init">
36 $(document).ready(function() {
37 var table = $('#example').DataTable( {
38 "order": [
1, 'asc' ],
39 "ajax":
"../../../examples/ajax/data/objects.txt",
41 { title: '', data: null, defaultContent:
"" },
42 { title: 'Name', data:
"name" },
43 { title: 'Position', data:
"position" },
44 { title: 'Office', data:
"office" },
45 { title: 'Extn.', data:
"extn" },
46 { title: 'Start date', data:
"start_date" },
47 { title: 'Salary', data:
"salary" },
48 { title: '', data: null, defaultContent:
"" }
50 initComplete: function () {
51 new $.fn.dataTable.FixedHeader( table, {
58 table.on( 'order.dt search.dt', function () {
59 table.column(
0, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
63 table.column(-
1, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
73 <body class=
"dt-example">
74 <div class=
"container">
76 <h1>FixedHeader example
<span>Header, left and right all fixed
</span></h1>
79 <p>FixedHeader provides the ability to fix in place the header, footer, left and right columns of the
80 table. These are controlled by the options:
</p>
83 <li><code>top
</code> - default true
</li>
84 <li><code>bottom
</code> - default false
</li>
85 <li><code>left
</code> - default false
</li>
86 <li><code>right
</code> - default false
</li>
89 <p>This example shows top, left and right enabled with index columns on the left and right.
</p>
91 <p>Note that in such a situation as this, the
<a href=
92 "//datatables.net/extensions/fixedcolumns">FixedColumns extension
</a> might be more useful,
93 particularly if you want to use the scrolling options built into DataTables.
</p>
96 <table id=
"example" class=
"display" cellspacing=
"0" width=
"100%"></table>
99 <li class=
"active">Javascript
</li>
103 <li>Server-side script
</li>
108 <p>The Javascript shown below is used to initialise the table shown in this
109 example:
</p><code class=
"multiline brush: js;">$(document).ready(function() {
110 var table = $('#example').DataTable( {
111 "order
": [
1, 'asc' ],
112 "ajax
":
"../../../examples/ajax/data/objects.txt
",
113 "columns
": [
114 { title: '', data: null, defaultContent:
"" },
115 { title: 'Name', data:
"name
" },
116 { title: 'Position', data:
"position
" },
117 { title: 'Office', data:
"office
" },
118 { title: 'Extn.', data:
"extn
" },
119 { title: 'Start date', data:
"start_date
" },
120 { title: 'Salary', data:
"salary
" },
121 { title: '', data: null, defaultContent:
"" }
123 initComplete: function () {
124 new $.fn.dataTable.FixedHeader( table, {
131 table.on( 'order.dt search.dt', function () {
132 table.column(
0, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
133 cell.innerHTML = i+
1;
136 table.column(-
1, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
137 cell.innerHTML = i+
1;
142 <p>In addition to the above code, the following Javascript library files are loaded for use in this
146 <li><a href=
"../../../media/js/jquery.js">../../../media/js/jquery.js
</a></li>
148 "../../../media/js/jquery.dataTables.js">../../../media/js/jquery.dataTables.js
</a></li>
149 <li><a href=
"../js/dataTables.fixedHeader.js">../js/dataTables.fixedHeader.js
</a></li>
154 <p>The HTML shown below is the raw HTML table element, before it has been enhanced by
160 <p>This example uses a little bit of additional CSS beyond what is loaded from the library
161 files (below), in order to correctly display the table. The additional CSS used is shown
162 below:
</p><code class=
"multiline brush: js;">div.dataTables_wrapper {
166 div.FixedHeader_Cloned.fixedLeft tbody td {
167 border-right:
1px solid black;
170 div.FixedHeader_Cloned.fixedRight tbody td {
171 border-left:
1px solid black;
175 <p>The following CSS library files are loaded for use in this example to provide the styling of the
180 "../../../media/css/jquery.dataTables.css">../../../media/css/jquery.dataTables.css
</a></li>
181 <li><a href=
"../css/dataTables.fixedHeader.css">../css/dataTables.fixedHeader.css
</a></li>
186 <p>This table loads data by Ajax. The latest data that has been loaded is shown below. This data
187 will update automatically as any additional data is loaded.
</p>
191 <p>The script used to perform the server-side processing for this table is shown below. Please note
192 that this is just an example script using PHP. Server-side processing scripts can be written in any
193 language, using
<a href=
"//datatables.net/manual/server-side">the protocol described in the
194 DataTables documentation
</a>.
</p>
202 <div class=
"gradient"></div>
205 <h2>Other examples
</h2>
208 <div class=
"toc-group">
209 <h3><a href=
"./index.html">Examples
</a></h3>
210 <ul class=
"toc active">
211 <li><a href=
"./simple.html">Basic initialisation
</a></li>
212 <li><a href=
"./header_footer.html">Header and footer fixed
</a></li>
213 <li class=
"active"><a href=
"./top_left_right.html">Header, left and right all
215 <li><a href=
"./two_tables.html">Multiple tables
</a></li>
216 <li><a href=
"./zIndexes.html">z-index order control
</a></li>
221 <div class=
"epilogue">
222 <p>Please refer to the
<a href=
"http://www.datatables.net">DataTables documentation
</a> for full
223 information about its API properties and methods.
<br>
224 Additionally, there are a wide range of
<a href=
"http://www.datatables.net/extras">extras
</a> and
225 <a href=
"http://www.datatables.net/plug-ins">plug-ins
</a> which extend the capabilities of
228 <p class=
"copyright">DataTables designed and created by
<a href=
229 "http://www.sprymedia.co.uk">SpryMedia Ltd
</a> © 2007-
2014<br>
230 DataTables is licensed under the
<a href=
"http://www.datatables.net/mit">MIT license
</a>.
</p>