]>
Commit | Line | Data |
---|---|---|
31f18b77 FG |
1 | <!DOCTYPE html> |
2 | <html> | |
3 | <head> | |
4 | <meta charset="utf-8"> | |
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"> | |
7 | ||
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"> | |
14 | ||
15 | div.dataTables_wrapper { | |
16 | width: 150%; | |
17 | } | |
18 | ||
19 | div.FixedHeader_Cloned.fixedLeft tbody td { | |
20 | border-right: 1px solid black; | |
21 | } | |
22 | ||
23 | div.FixedHeader_Cloned.fixedRight tbody td { | |
24 | border-left: 1px solid black; | |
25 | } | |
26 | ||
27 | </style> | |
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"> | |
34 | ||
35 | ||
36 | $(document).ready(function() { | |
37 | var table = $('#example').DataTable( { | |
38 | "order": [ 1, 'asc' ], | |
39 | "ajax": "../../../examples/ajax/data/objects.txt", | |
40 | "columns": [ | |
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: "" } | |
49 | ], | |
50 | initComplete: function () { | |
51 | new $.fn.dataTable.FixedHeader( table, { | |
52 | left: true, | |
53 | right: true | |
54 | } ); | |
55 | } | |
56 | } ); | |
57 | ||
58 | table.on( 'order.dt search.dt', function () { | |
59 | table.column(0, {search:'applied', order:'applied'}).nodes().each( function (cell, i) { | |
60 | cell.innerHTML = i+1; | |
61 | } ); | |
62 | ||
63 | table.column(-1, {search:'applied', order:'applied'}).nodes().each( function (cell, i) { | |
64 | cell.innerHTML = i+1; | |
65 | } ); | |
66 | } ).draw(); | |
67 | } ); | |
68 | ||
69 | ||
70 | </script> | |
71 | </head> | |
72 | ||
73 | <body class="dt-example"> | |
74 | <div class="container"> | |
75 | <section> | |
76 | <h1>FixedHeader example <span>Header, left and right all fixed</span></h1> | |
77 | ||
78 | <div class="info"> | |
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> | |
81 | ||
82 | <ul class="markdown"> | |
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> | |
87 | </ul> | |
88 | ||
89 | <p>This example shows top, left and right enabled with index columns on the left and right.</p> | |
90 | ||
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> | |
94 | </div> | |
95 | ||
96 | <table id="example" class="display" cellspacing="0" width="100%"></table> | |
97 | ||
98 | <ul class="tabs"> | |
99 | <li class="active">Javascript</li> | |
100 | <li>HTML</li> | |
101 | <li>CSS</li> | |
102 | <li>Ajax</li> | |
103 | <li>Server-side script</li> | |
104 | </ul> | |
105 | ||
106 | <div class="tabs"> | |
107 | <div class="js"> | |
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: "" } | |
122 | ], | |
123 | initComplete: function () { | |
124 | new $.fn.dataTable.FixedHeader( table, { | |
125 | left: true, | |
126 | right: true | |
127 | } ); | |
128 | } | |
129 | } ); | |
130 | ||
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; | |
134 | } ); | |
135 | ||
136 | table.column(-1, {search:'applied', order:'applied'}).nodes().each( function (cell, i) { | |
137 | cell.innerHTML = i+1; | |
138 | } ); | |
139 | } ).draw(); | |
140 | } );</code> | |
141 | ||
142 | <p>In addition to the above code, the following Javascript library files are loaded for use in this | |
143 | example:</p> | |
144 | ||
145 | <ul> | |
146 | <li><a href="../../../media/js/jquery.js">../../../media/js/jquery.js</a></li> | |
147 | <li><a href= | |
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> | |
150 | </ul> | |
151 | </div> | |
152 | ||
153 | <div class="table"> | |
154 | <p>The HTML shown below is the raw HTML table element, before it has been enhanced by | |
155 | DataTables:</p> | |
156 | </div> | |
157 | ||
158 | <div class="css"> | |
159 | <div> | |
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 { | |
163 | width: 150%; | |
164 | } | |
165 | ||
166 | div.FixedHeader_Cloned.fixedLeft tbody td { | |
167 | border-right: 1px solid black; | |
168 | } | |
169 | ||
170 | div.FixedHeader_Cloned.fixedRight tbody td { | |
171 | border-left: 1px solid black; | |
172 | }</code> | |
173 | </div> | |
174 | ||
175 | <p>The following CSS library files are loaded for use in this example to provide the styling of the | |
176 | table:</p> | |
177 | ||
178 | <ul> | |
179 | <li><a href= | |
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> | |
182 | </ul> | |
183 | </div> | |
184 | ||
185 | <div class="ajax"> | |
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> | |
188 | </div> | |
189 | ||
190 | <div class="php"> | |
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> | |
195 | </div> | |
196 | </div> | |
197 | </section> | |
198 | </div> | |
199 | ||
200 | <section> | |
201 | <div class="footer"> | |
202 | <div class="gradient"></div> | |
203 | ||
204 | <div class="liner"> | |
205 | <h2>Other examples</h2> | |
206 | ||
207 | <div class="toc"> | |
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 | |
214 | fixed</a></li> | |
215 | <li><a href="./two_tables.html">Multiple tables</a></li> | |
216 | <li><a href="./zIndexes.html">z-index order control</a></li> | |
217 | </ul> | |
218 | </div> | |
219 | </div> | |
220 | ||
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 | |
226 | DataTables.</p> | |
227 | ||
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> | |
231 | </div> | |
232 | </div> | |
233 | </div> | |
234 | </section> | |
235 | </body> | |
236 | </html> |