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

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
4 lars 1
/**
2
 * Much like `fnFindCellRowIndexes` this plug-in will search a table for
3
 * matching data (optionally the search can be restricted to a single column),
4
 * but in this case the returned array contains `dt-tag tr` nodes of the
5
 * matching rows, rather than data indexes.
6
 *
7
 *  @name fnFindCellRowNodes
8
 *  @summary Search for data, returning row nodes
9
 *  @author [Allan Jardine](http://sprymedia.co.uk)
10
 *
11
 *  @param {string} sSearch Data to search for
12
 *  @param {integer} [iColumn=null] Limit search to this column
13
 *  @returns {array} Array of `dt-tag tr` element with this data
14
 *
15
 *  @example
16
 *    $(document).ready(function() {
17
 *        var table = $('#example').dataTable();
18
 *
19
 *        var a = table.fnFindCellRowNodes( '1.7' );    // Search all columns
20
 *
21
 *        var b = table.fnFindCellRowNodes( '1.7', 3 ); // Search only column 3
22
 *    } );
23
 */
24
 
25
jQuery.fn.dataTableExt.oApi.fnFindCellRowNodes = function ( oSettings, sSearch, iColumn )
26
{
27
	var
28
		i,iLen, j, jLen, val,
29
		aOut = [], aData,
30
		columns = oSettings.aoColumns;
31
 
32
	for ( i=0, iLen=oSettings.aoData.length ; i<iLen ; i++ )
33
	{
34
		aData = oSettings.aoData[i]._aData;
35
 
36
		if ( iColumn === undefined )
37
		{
38
			for ( j=0, jLen=columns.length ; j<jLen ; j++ )
39
			{
40
				val = this.fnGetData(i, j);
41
 
42
				if ( val == sSearch )
43
				{
44
					aOut.push( oSettings.aoData[i].nTr );
45
				}
46
			}
47
		}
48
		else if (this.fnGetData(i, iColumn) == sSearch )
49
		{
50
			aOut.push( oSettings.aoData[i].nTr );
51
		}
52
	}
53
 
54
	return aOut;
55
};