FixedColumns example - left and right columns fixed

Preamble

FixedColumns allows columns to be fixed from both the left and right hand sides of the table. Fixing right hand-side columns is done by using the iRightColumns initialisation parameter, which works just the same as iLeftColumns does for the left side of the table. This example shows both the left and right columns being fixed in place, and a bit of initialisation of DataTables to provide index columns.

Live example

  Rendering engine Browser Platform(s) Engine version CSS grade  
  Rendering engine Browser Platform(s) Engine version CSS grade  
1 Trident Internet Explorer 4.0 Win 95+ 4 X 1
2 Trident Internet Explorer 5.0 Win 95+ 5 C 2
3 Trident Internet Explorer 5.5 Win 95+ 5.5 A 3
4 Trident Internet Explorer 6 Win 98+ 6 A 4
5 Trident Internet Explorer 7 Win XP SP2+ 7 A 5
6 Trident AOL browser (AOL desktop) Win XP 6 A 6
7 Gecko Firefox 1.0 Win 98+ / OSX.2+ 1.7 A 7
8 Gecko Firefox 1.5 Win 98+ / OSX.2+ 1.8 A 8
9 Gecko Firefox 2.0 Win 98+ / OSX.2+ 1.8 A 9
10 Gecko Firefox 3.0 Win 2k+ / OSX.3+ 1.9 A 10
11 Gecko Camino 1.0 OSX.2+ 1.8 A 11
12 Gecko Camino 1.5 OSX.3+ 1.8 A 12
13 Gecko Netscape 7.2 Win 95+ / Mac OS 8.6-9.2 1.7 A 13
14 Gecko Netscape Browser 8 Win 98SE+ 1.7 A 14
15 Gecko Netscape Navigator 9 Win 98+ / OSX.2+ 1.8 A 15
16 Gecko Mozilla 1.0 Win 95+ / OSX.1+ 1 A 16
17 Gecko Mozilla 1.1 Win 95+ / OSX.1+ 1.1 A 17
18 Gecko Mozilla 1.2 Win 95+ / OSX.1+ 1.2 A 18
19 Gecko Mozilla 1.3 Win 95+ / OSX.1+ 1.3 A 19
20 Gecko Mozilla 1.4 Win 95+ / OSX.1+ 1.4 A 20
21 Gecko Mozilla 1.5 Win 95+ / OSX.1+ 1.5 A 21
22 Gecko Mozilla 1.6 Win 95+ / OSX.1+ 1.6 A 22
23 Gecko Mozilla 1.7 Win 98+ / OSX.1+ 1.7 A 23
24 Gecko Mozilla 1.8 Win 98+ / OSX.1+ 1.8 A 24
25 Gecko Seamonkey 1.1 Win 98+ / OSX.2+ 1.8 A 25
26 Gecko Epiphany 2.20 Gnome 1.8 A 26
27 Webkit Safari 1.2 OSX.3 125.5 A 27
28 Webkit Safari 1.3 OSX.3 312.8 A 28
29 Webkit Safari 2.0 OSX.4+ 419.3 A 29
30 Webkit Safari 3.0 OSX.4+ 522.1 A 30
31 Webkit OmniWeb 5.5 OSX.4+ 420 A 31
32 Webkit iPod Touch / iPhone iPod 420.1 A 32
33 Webkit S60 S60 413 A 33
34 Presto Opera 7.0 Win 95+ / OSX.1+ - A 34
35 Presto Opera 7.5 Win 95+ / OSX.2+ - A 35
36 Presto Opera 8.0 Win 95+ / OSX.2+ - A 36
37 Presto Opera 8.5 Win 95+ / OSX.2+ - A 37
38 Presto Opera 9.0 Win 95+ / OSX.3+ - A 38
39 Presto Opera 9.2 Win 88+ / OSX.3+ - A 39
40 Presto Opera 9.5 Win 88+ / OSX.3+ - A 40
41 Presto Opera for Wii Wii - A 41
42 Presto Nokia N800 N800 - A 42
43 Presto Nintendo DS browser Nintendo DS 8.5 C/A 43
44 KHTML Konqureror 3.1 KDE 3.1 3.1 C 44
45 KHTML Konqureror 3.3 KDE 3.3 3.3 A 45
46 KHTML Konqureror 3.5 KDE 3.5 3.5 A 46
47 Tasman Internet Explorer 4.5 Mac OS 8-9 - X 47
48 Tasman Internet Explorer 5.1 Mac OS 7.6-9 1 C 48
49 Tasman Internet Explorer 5.2 Mac OS 8-X 1 C 49
50 Misc NetFront 3.1 Embedded devices - C 50
51 Misc NetFront 3.4 Embedded devices - A 51
52 Misc Dillo 0.8 Embedded devices - X 52
53 Misc Links Text only - X 53
54 Misc Lynx Text only - X 54
55 Misc IE Mobile Windows Mobile 6 - C 55
56 Misc PSP browser PSP - C 56
57 Other browsers All others - - U 57

Initialisation code

$(document).ready( function () {
	var oTable = $('#example').dataTable( {
		"sScrollX": "100%",
		"sScrollXInner": "150%",
		"bScrollCollapse": true,
		"fnDrawCallback": function ( oSettings ) {
			/* Need to redo the counters if filtered or sorted */
			if ( oSettings.bSorted || oSettings.bFiltered ) {
				for ( var i=0, iLen=oSettings.aiDisplay.length ; i<iLen ; i++ ) {
					this.fnUpdate( i+1, oSettings.aiDisplay[i], 0, false, false );
					this.fnUpdate( i+1, oSettings.aiDisplay[i], 6, false, false );
				}
			}
		},
		"aoColumnDefs": [
			{ "bSortable": false, "sClass": "indexLeft", "aTargets": [ 0 ] },
			{ "bSortable": false, "sClass": "indexRight", "aTargets": [ -1 ] }
		],
		"aaSorting": [[ 1, 'asc' ]]
	} );
	
	new FixedColumns( oTable, {
		"iLeftColumns": 1,
		"iRightColumns": 1
	} );
} );

Documentation

Basic examples

Advanced examples