Project

General

Profile

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>ColVis example - Basic initialisation</title>
9
	<link rel="stylesheet" type="text/css" href="../../../media/css/jquery.dataTables.css">
10
	<link rel="stylesheet" type="text/css" href="../css/dataTables.colVis.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
	</style>
16
	<script type="text/javascript" language="javascript" src="../../../media/js/jquery.js"></script>
17
	<script type="text/javascript" language="javascript" src="../../../media/js/jquery.dataTables.js"></script>
18
	<script type="text/javascript" language="javascript" src="../js/dataTables.colVis.js"></script>
19
	<script type="text/javascript" language="javascript" src="../../../examples/resources/syntax/shCore.js"></script>
20
	<script type="text/javascript" language="javascript" src="../../../examples/resources/demo.js"></script>
21
	<script type="text/javascript" language="javascript" class="init">
22

    
23

    
24
$(document).ready(function() {
25
	$('#example').DataTable( {
26
		dom: 'C<"clear">lfrtip'
27
	} );
28
} );
29

    
30

    
31
	</script>
32
</head>
33

    
34
<body class="dt-example">
35
	<div class="container">
36
		<section>
37
			<h1>ColVis example <span>Basic initialisation</span></h1>
38

    
39
			<div class="info">
40
				<p>ColVis is a plug-in for DataTables which presents a list of all columns to a user and allows them to
41
				select which ones they wish to be visible. Click the 'Show / hide columns' button to be presented with
42
				a list of columns in the table, and click the buttons to show and hide them as you wish.</p>
43

    
44
				<p>ColVis is added to a DataTable by specifying the <code>C</code> option for <a href=
45
				"//datatables.net/reference/option/dom"><code class="option" title=
46
				"DataTables initialisation option">dom<span>DT</span></code></a>. The example below shows the ColVis
47
				button added to the table with a clearing element after it.</p>
48
			</div>
49

    
50
			<table id="example" class="display" cellspacing="0" width="100%">
51
				<thead>
52
					<tr>
53
						<th>Name</th>
54
						<th>Position</th>
55
						<th>Office</th>
56
						<th>Age</th>
57
						<th>Start date</th>
58
						<th>Salary</th>
59
					</tr>
60
				</thead>
61

    
62
				<tfoot>
63
					<tr>
64
						<th>Name</th>
65
						<th>Position</th>
66
						<th>Office</th>
67
						<th>Age</th>
68
						<th>Start date</th>
69
						<th>Salary</th>
70
					</tr>
71
				</tfoot>
72

    
73
				<tbody>
74
					<tr>
75
						<td>Tiger Nixon</td>
76
						<td>System Architect</td>
77
						<td>Edinburgh</td>
78
						<td>61</td>
79
						<td>2011/04/25</td>
80
						<td>$320,800</td>
81
					</tr>
82
					<tr>
83
						<td>Garrett Winters</td>
84
						<td>Accountant</td>
85
						<td>Tokyo</td>
86
						<td>63</td>
87
						<td>2011/07/25</td>
88
						<td>$170,750</td>
89
					</tr>
90
					<tr>
91
						<td>Ashton Cox</td>
92
						<td>Junior Technical Author</td>
93
						<td>San Francisco</td>
94
						<td>66</td>
95
						<td>2009/01/12</td>
96
						<td>$86,000</td>
97
					</tr>
98
					<tr>
99
						<td>Cedric Kelly</td>
100
						<td>Senior Javascript Developer</td>
101
						<td>Edinburgh</td>
102
						<td>22</td>
103
						<td>2012/03/29</td>
104
						<td>$433,060</td>
105
					</tr>
106
					<tr>
107
						<td>Airi Satou</td>
108
						<td>Accountant</td>
109
						<td>Tokyo</td>
110
						<td>33</td>
111
						<td>2008/11/28</td>
112
						<td>$162,700</td>
113
					</tr>
114
					<tr>
115
						<td>Brielle Williamson</td>
116
						<td>Integration Specialist</td>
117
						<td>New York</td>
118
						<td>61</td>
119
						<td>2012/12/02</td>
120
						<td>$372,000</td>
121
					</tr>
122
					<tr>
123
						<td>Herrod Chandler</td>
124
						<td>Sales Assistant</td>
125
						<td>San Francisco</td>
126
						<td>59</td>
127
						<td>2012/08/06</td>
128
						<td>$137,500</td>
129
					</tr>
130
					<tr>
131
						<td>Rhona Davidson</td>
132
						<td>Integration Specialist</td>
133
						<td>Tokyo</td>
134
						<td>55</td>
135
						<td>2010/10/14</td>
136
						<td>$327,900</td>
137
					</tr>
138
					<tr>
139
						<td>Colleen Hurst</td>
140
						<td>Javascript Developer</td>
141
						<td>San Francisco</td>
142
						<td>39</td>
143
						<td>2009/09/15</td>
144
						<td>$205,500</td>
145
					</tr>
146
					<tr>
147
						<td>Sonya Frost</td>
148
						<td>Software Engineer</td>
149
						<td>Edinburgh</td>
150
						<td>23</td>
151
						<td>2008/12/13</td>
152
						<td>$103,600</td>
153
					</tr>
154
					<tr>
155
						<td>Jena Gaines</td>
156
						<td>Office Manager</td>
157
						<td>London</td>
158
						<td>30</td>
159
						<td>2008/12/19</td>
160
						<td>$90,560</td>
161
					</tr>
162
					<tr>
163
						<td>Quinn Flynn</td>
164
						<td>Support Lead</td>
165
						<td>Edinburgh</td>
166
						<td>22</td>
167
						<td>2013/03/03</td>
168
						<td>$342,000</td>
169
					</tr>
170
					<tr>
171
						<td>Charde Marshall</td>
172
						<td>Regional Director</td>
173
						<td>San Francisco</td>
174
						<td>36</td>
175
						<td>2008/10/16</td>
176
						<td>$470,600</td>
177
					</tr>
178
					<tr>
179
						<td>Haley Kennedy</td>
180
						<td>Senior Marketing Designer</td>
181
						<td>London</td>
182
						<td>43</td>
183
						<td>2012/12/18</td>
184
						<td>$313,500</td>
185
					</tr>
186
					<tr>
187
						<td>Tatyana Fitzpatrick</td>
188
						<td>Regional Director</td>
189
						<td>London</td>
190
						<td>19</td>
191
						<td>2010/03/17</td>
192
						<td>$385,750</td>
193
					</tr>
194
					<tr>
195
						<td>Michael Silva</td>
196
						<td>Marketing Designer</td>
197
						<td>London</td>
198
						<td>66</td>
199
						<td>2012/11/27</td>
200
						<td>$198,500</td>
201
					</tr>
202
					<tr>
203
						<td>Paul Byrd</td>
204
						<td>Chief Financial Officer (CFO)</td>
205
						<td>New York</td>
206
						<td>64</td>
207
						<td>2010/06/09</td>
208
						<td>$725,000</td>
209
					</tr>
210
					<tr>
211
						<td>Gloria Little</td>
212
						<td>Systems Administrator</td>
213
						<td>New York</td>
214
						<td>59</td>
215
						<td>2009/04/10</td>
216
						<td>$237,500</td>
217
					</tr>
218
					<tr>
219
						<td>Bradley Greer</td>
220
						<td>Software Engineer</td>
221
						<td>London</td>
222
						<td>41</td>
223
						<td>2012/10/13</td>
224
						<td>$132,000</td>
225
					</tr>
226
					<tr>
227
						<td>Dai Rios</td>
228
						<td>Personnel Lead</td>
229
						<td>Edinburgh</td>
230
						<td>35</td>
231
						<td>2012/09/26</td>
232
						<td>$217,500</td>
233
					</tr>
234
					<tr>
235
						<td>Jenette Caldwell</td>
236
						<td>Development Lead</td>
237
						<td>New York</td>
238
						<td>30</td>
239
						<td>2011/09/03</td>
240
						<td>$345,000</td>
241
					</tr>
242
					<tr>
243
						<td>Yuri Berry</td>
244
						<td>Chief Marketing Officer (CMO)</td>
245
						<td>New York</td>
246
						<td>40</td>
247
						<td>2009/06/25</td>
248
						<td>$675,000</td>
249
					</tr>
250
					<tr>
251
						<td>Caesar Vance</td>
252
						<td>Pre-Sales Support</td>
253
						<td>New York</td>
254
						<td>21</td>
255
						<td>2011/12/12</td>
256
						<td>$106,450</td>
257
					</tr>
258
					<tr>
259
						<td>Doris Wilder</td>
260
						<td>Sales Assistant</td>
261
						<td>Sidney</td>
262
						<td>23</td>
263
						<td>2010/09/20</td>
264
						<td>$85,600</td>
265
					</tr>
266
					<tr>
267
						<td>Angelica Ramos</td>
268
						<td>Chief Executive Officer (CEO)</td>
269
						<td>London</td>
270
						<td>47</td>
271
						<td>2009/10/09</td>
272
						<td>$1,200,000</td>
273
					</tr>
274
					<tr>
275
						<td>Gavin Joyce</td>
276
						<td>Developer</td>
277
						<td>Edinburgh</td>
278
						<td>42</td>
279
						<td>2010/12/22</td>
280
						<td>$92,575</td>
281
					</tr>
282
					<tr>
283
						<td>Jennifer Chang</td>
284
						<td>Regional Director</td>
285
						<td>Singapore</td>
286
						<td>28</td>
287
						<td>2010/11/14</td>
288
						<td>$357,650</td>
289
					</tr>
290
					<tr>
291
						<td>Brenden Wagner</td>
292
						<td>Software Engineer</td>
293
						<td>San Francisco</td>
294
						<td>28</td>
295
						<td>2011/06/07</td>
296
						<td>$206,850</td>
297
					</tr>
298
					<tr>
299
						<td>Fiona Green</td>
300
						<td>Chief Operating Officer (COO)</td>
301
						<td>San Francisco</td>
302
						<td>48</td>
303
						<td>2010/03/11</td>
304
						<td>$850,000</td>
305
					</tr>
306
					<tr>
307
						<td>Shou Itou</td>
308
						<td>Regional Marketing</td>
309
						<td>Tokyo</td>
310
						<td>20</td>
311
						<td>2011/08/14</td>
312
						<td>$163,000</td>
313
					</tr>
314
					<tr>
315
						<td>Michelle House</td>
316
						<td>Integration Specialist</td>
317
						<td>Sidney</td>
318
						<td>37</td>
319
						<td>2011/06/02</td>
320
						<td>$95,400</td>
321
					</tr>
322
					<tr>
323
						<td>Suki Burks</td>
324
						<td>Developer</td>
325
						<td>London</td>
326
						<td>53</td>
327
						<td>2009/10/22</td>
328
						<td>$114,500</td>
329
					</tr>
330
					<tr>
331
						<td>Prescott Bartlett</td>
332
						<td>Technical Author</td>
333
						<td>London</td>
334
						<td>27</td>
335
						<td>2011/05/07</td>
336
						<td>$145,000</td>
337
					</tr>
338
					<tr>
339
						<td>Gavin Cortez</td>
340
						<td>Team Leader</td>
341
						<td>San Francisco</td>
342
						<td>22</td>
343
						<td>2008/10/26</td>
344
						<td>$235,500</td>
345
					</tr>
346
					<tr>
347
						<td>Martena Mccray</td>
348
						<td>Post-Sales support</td>
349
						<td>Edinburgh</td>
350
						<td>46</td>
351
						<td>2011/03/09</td>
352
						<td>$324,050</td>
353
					</tr>
354
					<tr>
355
						<td>Unity Butler</td>
356
						<td>Marketing Designer</td>
357
						<td>San Francisco</td>
358
						<td>47</td>
359
						<td>2009/12/09</td>
360
						<td>$85,675</td>
361
					</tr>
362
					<tr>
363
						<td>Howard Hatfield</td>
364
						<td>Office Manager</td>
365
						<td>San Francisco</td>
366
						<td>51</td>
367
						<td>2008/12/16</td>
368
						<td>$164,500</td>
369
					</tr>
370
					<tr>
371
						<td>Hope Fuentes</td>
372
						<td>Secretary</td>
373
						<td>San Francisco</td>
374
						<td>41</td>
375
						<td>2010/02/12</td>
376
						<td>$109,850</td>
377
					</tr>
378
					<tr>
379
						<td>Vivian Harrell</td>
380
						<td>Financial Controller</td>
381
						<td>San Francisco</td>
382
						<td>62</td>
383
						<td>2009/02/14</td>
384
						<td>$452,500</td>
385
					</tr>
386
					<tr>
387
						<td>Timothy Mooney</td>
388
						<td>Office Manager</td>
389
						<td>London</td>
390
						<td>37</td>
391
						<td>2008/12/11</td>
392
						<td>$136,200</td>
393
					</tr>
394
					<tr>
395
						<td>Jackson Bradshaw</td>
396
						<td>Director</td>
397
						<td>New York</td>
398
						<td>65</td>
399
						<td>2008/09/26</td>
400
						<td>$645,750</td>
401
					</tr>
402
					<tr>
403
						<td>Olivia Liang</td>
404
						<td>Support Engineer</td>
405
						<td>Singapore</td>
406
						<td>64</td>
407
						<td>2011/02/03</td>
408
						<td>$234,500</td>
409
					</tr>
410
					<tr>
411
						<td>Bruno Nash</td>
412
						<td>Software Engineer</td>
413
						<td>London</td>
414
						<td>38</td>
415
						<td>2011/05/03</td>
416
						<td>$163,500</td>
417
					</tr>
418
					<tr>
419
						<td>Sakura Yamamoto</td>
420
						<td>Support Engineer</td>
421
						<td>Tokyo</td>
422
						<td>37</td>
423
						<td>2009/08/19</td>
424
						<td>$139,575</td>
425
					</tr>
426
					<tr>
427
						<td>Thor Walton</td>
428
						<td>Developer</td>
429
						<td>New York</td>
430
						<td>61</td>
431
						<td>2013/08/11</td>
432
						<td>$98,540</td>
433
					</tr>
434
					<tr>
435
						<td>Finn Camacho</td>
436
						<td>Support Engineer</td>
437
						<td>San Francisco</td>
438
						<td>47</td>
439
						<td>2009/07/07</td>
440
						<td>$87,500</td>
441
					</tr>
442
					<tr>
443
						<td>Serge Baldwin</td>
444
						<td>Data Coordinator</td>
445
						<td>Singapore</td>
446
						<td>64</td>
447
						<td>2012/04/09</td>
448
						<td>$138,575</td>
449
					</tr>
450
					<tr>
451
						<td>Zenaida Frank</td>
452
						<td>Software Engineer</td>
453
						<td>New York</td>
454
						<td>63</td>
455
						<td>2010/01/04</td>
456
						<td>$125,250</td>
457
					</tr>
458
					<tr>
459
						<td>Zorita Serrano</td>
460
						<td>Software Engineer</td>
461
						<td>San Francisco</td>
462
						<td>56</td>
463
						<td>2012/06/01</td>
464
						<td>$115,000</td>
465
					</tr>
466
					<tr>
467
						<td>Jennifer Acosta</td>
468
						<td>Junior Javascript Developer</td>
469
						<td>Edinburgh</td>
470
						<td>43</td>
471
						<td>2013/02/01</td>
472
						<td>$75,650</td>
473
					</tr>
474
					<tr>
475
						<td>Cara Stevens</td>
476
						<td>Sales Assistant</td>
477
						<td>New York</td>
478
						<td>46</td>
479
						<td>2011/12/06</td>
480
						<td>$145,600</td>
481
					</tr>
482
					<tr>
483
						<td>Hermione Butler</td>
484
						<td>Regional Director</td>
485
						<td>London</td>
486
						<td>47</td>
487
						<td>2011/03/21</td>
488
						<td>$356,250</td>
489
					</tr>
490
					<tr>
491
						<td>Lael Greer</td>
492
						<td>Systems Administrator</td>
493
						<td>London</td>
494
						<td>21</td>
495
						<td>2009/02/27</td>
496
						<td>$103,500</td>
497
					</tr>
498
					<tr>
499
						<td>Jonas Alexander</td>
500
						<td>Developer</td>
501
						<td>San Francisco</td>
502
						<td>30</td>
503
						<td>2010/07/14</td>
504
						<td>$86,500</td>
505
					</tr>
506
					<tr>
507
						<td>Shad Decker</td>
508
						<td>Regional Director</td>
509
						<td>Edinburgh</td>
510
						<td>51</td>
511
						<td>2008/11/13</td>
512
						<td>$183,000</td>
513
					</tr>
514
					<tr>
515
						<td>Michael Bruce</td>
516
						<td>Javascript Developer</td>
517
						<td>Singapore</td>
518
						<td>29</td>
519
						<td>2011/06/27</td>
520
						<td>$183,000</td>
521
					</tr>
522
					<tr>
523
						<td>Donna Snider</td>
524
						<td>Customer Support</td>
525
						<td>New York</td>
526
						<td>27</td>
527
						<td>2011/01/25</td>
528
						<td>$112,000</td>
529
					</tr>
530
				</tbody>
531
			</table>
532

    
533
			<ul class="tabs">
534
				<li class="active">Javascript</li>
535
				<li>HTML</li>
536
				<li>CSS</li>
537
				<li>Ajax</li>
538
				<li>Server-side script</li>
539
			</ul>
540

    
541
			<div class="tabs">
542
				<div class="js">
543
					<p>The Javascript shown below is used to initialise the table shown in this
544
					example:</p><code class="multiline brush: js;">$(document).ready(function() {
545
	$('#example').DataTable( {
546
		dom: 'C&lt;&quot;clear&quot;&gt;lfrtip'
547
	} );
548
} );</code>
549

    
550
					<p>In addition to the above code, the following Javascript library files are loaded for use in this
551
					example:</p>
552

    
553
					<ul>
554
						<li><a href="../../../media/js/jquery.js">../../../media/js/jquery.js</a></li>
555
						<li><a href=
556
						"../../../media/js/jquery.dataTables.js">../../../media/js/jquery.dataTables.js</a></li>
557
						<li><a href="../js/dataTables.colVis.js">../js/dataTables.colVis.js</a></li>
558
					</ul>
559
				</div>
560

    
561
				<div class="table">
562
					<p>The HTML shown below is the raw HTML table element, before it has been enhanced by
563
					DataTables:</p>
564
				</div>
565

    
566
				<div class="css">
567
					<div>
568
						<p>This example uses a little bit of additional CSS beyond what is loaded from the library
569
						files (below), in order to correctly display the table. The additional CSS used is shown
570
						below:</p><code class="multiline brush: js;"></code>
571
					</div>
572

    
573
					<p>The following CSS library files are loaded for use in this example to provide the styling of the
574
					table:</p>
575

    
576
					<ul>
577
						<li><a href=
578
						"../../../media/css/jquery.dataTables.css">../../../media/css/jquery.dataTables.css</a></li>
579
						<li><a href="../css/dataTables.colVis.css">../css/dataTables.colVis.css</a></li>
580
					</ul>
581
				</div>
582

    
583
				<div class="ajax">
584
					<p>This table loads data by Ajax. The latest data that has been loaded is shown below. This data
585
					will update automatically as any additional data is loaded.</p>
586
				</div>
587

    
588
				<div class="php">
589
					<p>The script used to perform the server-side processing for this table is shown below. Please note
590
					that this is just an example script using PHP. Server-side processing scripts can be written in any
591
					language, using <a href="//datatables.net/manual/server-side">the protocol described in the
592
					DataTables documentation</a>.</p>
593
				</div>
594
			</div>
595
		</section>
596
	</div>
597

    
598
	<section>
599
		<div class="footer">
600
			<div class="gradient"></div>
601

    
602
			<div class="liner">
603
				<h2>Other examples</h2>
604

    
605
				<div class="toc">
606
					<div class="toc-group">
607
						<h3><a href="./index.html">Examples</a></h3>
608
						<ul class="toc active">
609
							<li class="active"><a href="./simple.html">Basic initialisation</a></li>
610
							<li><a href="./new_init.html">`new` initialisation</a></li>
611
							<li><a href="./text.html">Custom button text</a></li>
612
							<li><a href="./exclude_columns.html">Exclude columns from list</a></li>
613
							<li><a href="./title_callback.html">Column button callback</a></li>
614
							<li><a href="./button_order.html">Button ordering</a></li>
615
							<li><a href="./mouseover.html">Mouseover activation</a></li>
616
							<li><a href="./group_columns.html">Group columns</a></li>
617
							<li><a href="./two_tables.html">Two tables with individual controls</a></li>
618
							<li><a href="./two_tables_identical.html">Two tables with shared controls</a></li>
619
							<li><a href="./restore.html">Restore / show all</a></li>
620
							<li><a href="./jqueryui.html">jQuery UI styling</a></li>
621
						</ul>
622
					</div>
623
				</div>
624

    
625
				<div class="epilogue">
626
					<p>Please refer to the <a href="http://www.datatables.net">DataTables documentation</a> for full
627
					information about its API properties and methods.<br>
628
					Additionally, there are a wide range of <a href="http://www.datatables.net/extras">extras</a> and
629
					<a href="http://www.datatables.net/plug-ins">plug-ins</a> which extend the capabilities of
630
					DataTables.</p>
631

    
632
					<p class="copyright">DataTables designed and created by <a href=
633
					"http://www.sprymedia.co.uk">SpryMedia Ltd</a> &#169; 2007-2014<br>
634
					DataTables is licensed under the <a href="http://www.datatables.net/mit">MIT license</a>.</p>
635
				</div>
636
			</div>
637
		</div>
638
	</section>
639
</body>
640
</html>
(9-9/13)