Subversion-Projekte lars-tiefland.webanos.zeldi.de

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
4 lars 1
/**
2
 * Maintenance of web-sites can often cause unexpected headaches, particularly
3
 * if the hardcoded index of an array (the columns in a DataTables instance)
4
 * needs to change due to an added or removed column. This plug-in function
5
 * will match a given string to the title of a column in the table and return
6
 * the column index, helping to overcome this problem.
7
 *
8
 *  @name fnGetColumnIndex
9
 *  @summary Get the column index by searching the column titles
10
 *  @author [Michael Ross](http://www.rosstechassociates.com/)
11
 *
12
 *  @param {string} sCol Column title to search for
13
 *  @returns {integer} Column index, or -1 if not found
14
 *
15
 *  @example
16
 *    var table = $('#example').dataTable();
17
 *    table.fnGetColumnIndex( 'Browser' );
18
 */
19
 
20
jQuery.fn.dataTableExt.oApi.fnGetColumnIndex = function ( oSettings, sCol )
21
{
22
	var cols = oSettings.aoColumns;
23
	for ( var x=0, xLen=cols.length ; x<xLen ; x++ )
24
	{
25
		if ( cols[x].sTitle.toLowerCase() == sCol.toLowerCase() )
26
		{
27
			return x;
28
		}
29
	}
30
	return -1;
31
};