DataTables events (post-initialisation) example

Preamble

Events which are assigned to the table elements are retained by DataTables such that they will still work as you would expect, even after changing the sort order etc. (no need to reapply the event handlers). You can do this at any time, although if you apply the handlers after the table has been initialised there is an extra set. Rather then queriing the DOM to get all rows (since they aren't there) you need to use the fnGetNodes() API function. This is shown in this example.

Live example

Show entries
Search:
Rendering engine Browser Platform(s) Engine version CSS grade
Gecko Firefox 1.0 Win 98+ / OSX.2+ 1.7 A
Gecko Firefox 1.5 Win 98+ / OSX.2+ 1.8 A
Gecko Firefox 2.0 Win 98+ / OSX.2+ 1.8 A
Gecko Firefox 3.0 Win 2k+ / OSX.3+ 1.9 A
Gecko Camino 1.0 OSX.2+ 1.8 A
Gecko Camino 1.5 OSX.3+ 1.8 A
Gecko Netscape 7.2 Win 95+ / Mac OS 8.6-9.2 1.7 A
Gecko Netscape Browser 8 Win 98SE+ 1.7 A
Gecko Netscape Navigator 9 Win 98+ / OSX.2+ 1.8 A
Gecko Mozilla 1.0 Win 95+ / OSX.1+ 1 A
Rendering engine Browser Platform(s) Engine version CSS grade
Showing 1 to 10 of 57 entries

Initialisation code

var oTable;

$(document).ready(function() {
	/*
	 * First step is to create title attributes for the rows in the table
	 * This isn't needed if the required 'title' attribute is already set in the HTML in the
	 * DOM 
	 */
	$('#example tbody tr').each( function() {
		var sTitle;
		var nTds = $('td', this);
		var sBrowser = $(nTds[1]).text();
		var sGrade = $(nTds[4]).text();
		
		if ( sGrade == "A" )
			sTitle =  sBrowser+' will provide a first class (A) level of CSS support.';
		else if ( sGrade == "C" )
			sTitle = sBrowser+' will provide a core (C) level of CSS support.';
		else if ( sGrade == "X" )
			sTitle = sBrowser+' does not provide CSS support or has a broken implementation. Block CSS.';
		else
			sTitle = sBrowser+' will provide an undefined level of CSS support.';
		
		this.setAttribute( 'title', sTitle );
	} );
	
	/* Init DataTables */
	oTable = $('#example').dataTable();
	
	/* Apply the tooltips */
	$( oTable.fnGetNodes() ).tooltip( {
		"delay": 0,
		"track": true,
		"fade": 250
	} );
} );

Other examples

Basic initialisation

Advanced initialisation

Data sources

Server-side processing

API

Plug-ins

Please refer to the DataTables documentation for full information about its API properties and methods.