forked from benjaminleouzon/tablefixedheader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
493 lines (431 loc) · 16.1 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
<?php
/**
* jquery.fixheadertable
*
* Copyright (c) 2010 Benjamin Léouzon
* http://www.tablefixedheader.com/
*
* Licensed under MIT
* http://www.opensource.org/licenses/mit-license.php
*
* Launch : December 2010
* Version : 2.0
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Full page demo | table fixed header</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/jquery-ui.min.js"></script>
<link rel="stylesheet" type="text/css" href="jquery-ui/css/redmond/jquery-ui-1.8.4.custom.css"/>
<link rel="stylesheet" type="text/css" href="jquery-ui/css/ui-lightness/jquery-ui-1.8.4.custom.css"/>
<link rel="stylesheet" type="text/css" href="jquery-ui/css/smoothness/jquery-ui-1.8.4.custom.css"/>
<link rel="stylesheet" type="text/css" href="jquery-ui/css/flick/jquery-ui-1.8.4.custom.css" id="link"/>
<link rel="stylesheet" type="text/css" href="css/base.css" />
<script type="text/javascript" src="highlighter/codehighlighter.js"></script>
<script type="text/javascript" src="highlighter/javascript.js"></script>
<script type="text/javascript" src="javascript/jquery.fixheadertable.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('div.title').each(function(i){
$(this).prepend('<a name="ex_' + (i+1) + '" />');
$('#links').append('<a title="' + $('span', this).html() + '" class="ui-state-default ui-corner-all" href="#ex_' + (i+1) + '"><span style="float: left; margin-right: 0.3em; margin-top : -2px;" class="ui-icon ui-icon-triangle-1-e"></span> Example #' + (i+1) + '</a>');
});
$('<br/><a style="cursor : pointer">[ Show code ]</a>').insertBefore('pre').click(function(){
if($(this).html() == "[ Show code ]"){
$(this).html("[ Hide code ]");
}else{
$(this).html("[ Show code ]");
}
$(this).next('pre').toggle();
});
$.ajax({
url: 'data.php',
success: function(data) {
$('#0').html(data).fixheadertable({
caption : 'My employees (200)',
colratio : [100, 150, 150, 150, 220, 150],
height : 300,
width : 800,
zebra : true,
sortable : true,
sortedColId : 1,
resizeCol : true,
pager : true,
rowsPerPage : 10,
sortType : ['integer', 'string', 'string', 'string', 'string', 'date'],
dateFormat : 'm/d/Y'
});
}
});
function buildtable(id, data) {
$(id).html(data);
if(id == "#1")
$('#1').fixheadertable({ height : 200, zebra : true });
if(id == "#2")
$('#2').fixheadertable({ caption : 'My employees', height : 200, width : 800 });
if(id == "#3")
$('#3').fixheadertable({ caption : 'My employees', height : 200, width : 800, minWidth : 1000 });
if(id == "#4")
$('#4').fixheadertable({ caption : 'My employees', colratio : [50, 150, 150, 150, 220, 150], height : 200, width : 800, zebra : true, resizeCol : true, minColWidth : 50 });
if(id == "#5")
$('#5').fixheadertable({ caption : 'My employees', colratio : [50, 150, 150, 150, 220, 150], height : 200, width : 800, zebra : true, sortable : true, sortedColId : 0,
sortType : ['integer', 'string', 'string', 'string', 'string', 'date'],
dateFormat : 'm/d/Y' });
if(id == "#6")
$('#6').fixheadertable({
caption : 'My employees',
colratio : [50, 150, 150, 150, 220, 150],
height : 200,
width : 800,
zebra : true,
sortable : true,
sortedColId : 2,
sortType : ['integer', 'string', 'string', 'string', 'string', 'date'],
dateFormat : 'm/d/Y',
pager : true,
rowsPerPage : 10
});
if(id == "#7")
$('#7').fixheadertable({
caption : 'My employees',
colratio : [50, 150, 150, 150, 220, 150],
height : 200,
width : 800,
zebra : true,
sortable : true,
sortedColId : 3,
sortType : ['integer', 'string', 'string', 'string', 'string', 'date'],
dateFormat : 'm/d/Y',
pager : true,
rowsPerPage : 10,
resizeCol : true
});
};
$("button").button();
$("button.loadexample").click(function(){
var button = this;
if($(button).attr('pass')) return;
$('span', this).append('<span class="text">loading...</span>');
$.ajax({
url: 'data.php',
success: function(data) {
buildtable($(button).attr('num'), data);
$('span.text', button).remove();
$('span.ui-button-text', button).html('Example loaded !');
$(button).attr('pass', 'pass');
}
});
});
$("#lightness").click(function() { $('#link').attr('href', 'jquery-ui/css/ui-lightness/jquery-ui-1.8.4.custom.css'); });
$("#flick").click(function() { $('#link').attr('href', 'jquery-ui/css/flick/jquery-ui-1.8.4.custom.css'); });
$("#redmond").click(function() { $('#link').attr('href', 'jquery-ui/css/redmond/jquery-ui-1.8.4.custom.css'); });
$("#smoothness").click(function() { $('#link').attr('href', 'jquery-ui/css/smoothness/jquery-ui-1.8.4.custom.css'); });
});
</script>
<style type="text/css">
body {
font-family : Verdana,Arial,Geneva,Helvetica,sans-serif;
font-size : 10px;
}
pre {
padding : 5px;
font-size : 12px;
border : 2px solid #F0F0F0;
background : #F5F5F5;
width : 100%;
display : none;
width : 800px
}
.javascript .comment {
color : green;
}
.javascript .string {
color : maroon;
}
.javascript .keywords {
font-weight : bold;
}
.javascript .global {
color : blue;
font-weight : bolder;
}
.javascript .brackets {
color : Gray;
}
.javascript .thing {
font-size : 10px;
}
span.text {
font-weight : normal;
font-style : italic;
margin-left : 10px;
}
div.title {
font-size : 18px;
padding : 15px 0;
font-weight : bold;
}
div.title span {
font-weight : normal;
}
div.themes {
overflow : hidden;
width : 150px;
position : fixed;
top : 180px;
left : 10px;
}
div.themes button {
width : 120px;
margin-bottom : 5px;
}
div.themes a {
display : block;
font-size : 1.1em;
margin-bottom : 5px;
text-decoration : none;
padding : 3px;
width : 120px;
}
div.themes a:focus {
outline : none;
}
div.themes a.top {
color : black;
}
div.themes a.top:hover {
text-decoration : underline;
}
</style>
</head>
<body style="background-color : #FFFFFF; overflow-x : hidden">
<div style="background: url(logo.png) no-repeat scroll 98% top transparent; height: 150px;margin:0 auto;padding:0;position:relative;text-align:left;width:980px;">
<div style="background:transparent none repeat scroll 0 0;height:8em;margin:7px 0 14px;padding:1em;">
<div style="width:100%">
<h1 style="font-family:'PT+Sans&subset=latin',Helvetica,Verdana,Arial,Sans-Serif;font-size:4em;margin:20px 0 0 8px;">
<a style="background:transparent none repeat scroll 0 0;color:#444444;outline-color:-moz-use-text-color;outline-style:none;outline-width:medium;text-decoration:none;" title="table fixed header" href="http://www.tablefixedheader.com/">table fixed header</a></h1>
<div style="color:#444444;font-family:'Lobster',Helvetica,Verdana,Arial,Sans-Serif;font-size:1.3em;margin:0.5em 0 0 8px;">A client-side jQuery plugin to transform your HTML table </div>
</div>
</div>
</div>
<div class="themes">
<h2>UI Themes</h2>
<button id="flick">FLICK</button><br/>
<button id="lightness">UI-LIGHTNESS</button><br/>
<button id="redmond">REDMOND</button><br/>
<button id="smoothness">SMOOTHNESS</button><br/>
<br/>
<h2>Examples</h2>
<div id="links"><a class="top" href="#">Back to the top</a><br/></div>
</div>
<br/>
<!-- EXAMPLES -->
<div style="position : relative; left : 50%; margin-left : -410px; width : 820px;">
<h2 style="font-family:Helvetica,Verdana,Arial,Sans-Serif;color:#444444;font-size:2.7em;font-weight:normal;letter-spacing:-0.05em;margin:0 0 0.5em;">Fullpage demo</h2>
<div style="border-top:2px solid #F1F2F4;padding:1em 0 0.5em;"></div>
<!-- THE EXAMPLE -->
<table class="resultset" id="0"></table>
<pre><code class="javascript">
$('#0').fixheadertable({
caption : 'My employees (200)',
colratio : [100, 150, 150, 150, 220, 150],
height : 300,
width : 800,
zebra : true,
sortable : true,
sortedColId : 1,
resizeCol : true,
pager : true,
rowsPerPage : 10,
sortType : ['integer', 'string', 'string', 'string', 'string', 'date'],
dateFormat : 'm/d/Y'
});
</code></pre>
<br/><br/>
<div style="border-top : 3px dashed black"> </div>
<!-- THE EXAMPLE #1 -->
<div class="title">Example #1 : Basic use <span>(just a fixed height and zebra)</span></div>
<button class="loadexample" num="#1">Load this example</button><br/><br/>
<table class="resultset" id="1"></table>
<pre><code class="javascript">
/**
* This is a basic use of the plugin. Just set the height option to
* have a fixed header table. You can also apply the zebra option which alternate
* the row style (you can change the applied class with the zebraClass option)
*/
$('#1').fixheadertable({
height : 200,
zebra : true,
zebraClass : 'ui-state-active' // default
});
</code></pre>
<br/><br/>
<div style="border-top : 3px dashed black"> </div>
<!-- THE EXAMPLE #2 -->
<div class="title">Example #2 : Basic use <span>(the same with a caption)</span></div>
<button class="loadexample" num="#2">Load this example</button><br/><br/>
<table class="resultset" id="2"></table>
<pre><code class="javascript">
/**
* This is a basic use too with the caption option.
* Note that natively, there will have a toggle arrow which allow you
* to show/hide your table. To disable it, set the showhide option to false.
*/
$('#2').fixheadertable({
caption : 'My employees',
showhide : true, // default
height : 200,
width : 800
});
</code></pre>
<br/><br/>
<div style="border-top : 3px dashed black"> </div>
<!-- THE EXAMPLE #3 -->
<div class="title">Example #3 : Medium use <span>(the min-width and horizontal scollbar)</span></div>
<button class="loadexample" num="#3">Load this example</button><br/><br/>
<table class="resultset" id="3"></table>
<pre><code class="javascript">
/**
* By default, the table and the columns will resize according to his parent's width.
* So if the container is not large enough, the column's overflow will be clipped.
* But through the minWidth option, you can set the minimum width before horizontal scrolling.
* You also have the minWidthAuto option, which let the plugin calculate a min-width automatically.
*/
$('#3').fixheadertable({
caption : 'My employees',
height : 200,
width : 800,
minWidth : 1000
});
</code></pre>
<br/><br/>
<div style="border-top : 3px dashed black"> </div>
<!-- THE EXAMPLE #4 -->
<div class="title">Example #4 : Medium use <span>(set the width and make them resizable)</span></div>
<button class="loadexample" num="#4">Load this example</button><br/><br/>
<table class="resultset" id="4"></table>
<pre><code class="javascript">
/**
* The colratio option allow you to set an exact width in pixel for each column. To be available,
* you need to fill the array with as much values as there are columns, else it won't work.
* (ex : 6 columns => 6 values) ;-)
* Note that each value means 'the width in pixel'
*
* Thanks to the resizeCol option, you can resize manually the columns. This option works ONLY if
* the colratio option is set and valid! you can set a min-width with the minColWidth option.
*/
$('#4').fixheadertable({
caption : 'My employees',
colratio : [50, 150, 150, 150, 220, 150],
height : 200,
width : 800,
zebra : true,
resizeCol : true,
minColWidth : 50
});
</code></pre>
<br/><br/>
<div style="border-top : 3px dashed black"> </div>
<!-- THE EXAMPLE #5 -->
<div class="title">Example #5 : Complex use <span>(sort your columns)</span></div>
<button class="loadexample" num="#5">Load this example</button><br/><br/>
<table class="resultset" id="5"></table>
<pre><code class="javascript">
/**
* The sortable option allow you to sort your columns. If the option is set, all the columns
* will be sortable. By default, the sort callback is 'string' but through the sortType option you
* can specify the type of sort.
* To be available, you need to fill the array with as much values as there are columns, else it won't work.
*
* Availables sort callbacks :
* - 'string' (default)
* - 'float'
* - 'integer'
* - 'date' (use with the dateFormat option : default 'd-m-y')
*
* The sortedColId option allow you to sort the column by default (specify the id of the column)
*/
$('#5').fixheadertable({
caption : 'My employees',
colratio : [50, 150, 150, 150, 220, 150],
height : 200,
width : 800,
zebra : true,
sortable : true,
sortedColId : 0,
sortType : ['integer', 'string', 'string', 'string', 'string', 'date'],
dateFormat : 'm/d/Y'
});
</code></pre>
<br/><br/>
<div style="border-top : 3px dashed black"> </div>
<!-- THE EXAMPLE #6 -->
<div class="title">Example #6 : Medium use <span>(pager)</span></div>
<button class="loadexample" num="#6">Load this example</button><br/><br/>
<table class="resultset" id="6"></table>
<pre><code class="javascript">
/**
* The pager option allow you the reduce the set of visible rows. More rows and columns
* you have, more the sort will be long for example. But not with the pager.
* Yo can also use the linked option rowsPerPage wich allow you to change the range (10, 25, 50 or 100).
*
* Use the navigation arrows to navigate through your table.
*/
$('#6').fixheadertable({
caption : 'My employees',
colratio : [50, 150, 150, 150, 220, 150],
height : 200,
width : 800,
zebra : true,
sortable : true,
sortedColId : 2,
sortType : ['integer', 'string', 'string', 'string', 'string', 'date'],
dateFormat : 'm/d/Y',
pager : true,
rowsPerPage : 10
});
</code></pre>
<br/><br/>
<div style="border-top : 3px dashed black"> </div>
<!-- THE EXAMPLE #7 -->
<div class="title">Example #7 : Complex use <span>(pager + sort + resize = a real data grid)</span></div>
<button class="loadexample" num="#7">Load this example</button><br/><br/>
<table class="resultset" id="7"></table>
<pre><code class="javascript">
/**
* This example takes back all the options viewed before.
*/
$('#7').fixheadertable({
caption : 'My employees',
colratio : [50, 150, 150, 150, 220, 150],
height : 200,
width : 800,
zebra : true,
sortable : true,
sortedColId : 3,
sortType : ['integer', 'string', 'string', 'string', 'string', 'date'],
dateFormat : 'm/d/Y',
pager : true,
rowsPerPage : 10,
resizeCol : true
});
</code></pre>
<br/><br/>
<div style="border-top : 3px dashed black"> </div>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
</div>
</body>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try{
var pageTracker = _gat._getTracker("UA-12814459-5");
pageTracker._trackPageview();
} catch(err) {}
</script>
</html>