Subversion-Projekte lars-tiefland.zeldi.de_alt

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
2 lars 1
/**
2
 * Get an array of `dt-tag td` nodes from DataTables for a given row, including
3
 * any column elements which are hidden.
4
 *
5
 * DataTables 1.10 has the `dt-api cells().nodes()` method, built-in, to provide
6
 * this functionality. As such this method is marked deprecated, but is
7
 * available for use with legacy version of DataTables. Please use the new API
8
 * if you are used DataTables 1.10 or newer.
9
 *
10
 *  @name fnGetTds
11
 *  @summary Get the `dt-tag td` elements for a row
12
 *  @author [Allan Jardine](http://sprymedia.co.uk)
13
 *  @deprecated
14
 *
15
 *  @param {node} mTr `dt-tag tr` element to get the `dt-tag td` of
16
 *  @returns {array} Array of `dt-tag td` elements
17
 *
18
 *  @example
19
 *    $(document).ready(function() {
20
 *        var oTable = $('#example').dataTable();
21
 *
22
 *        // Sort in the order that was origially in the HTML
23
 *        var anTds = oTable.fnGetTds( $('#example tbody tr:eq(1)')[0] );
24
 *        console.log( anTds );
25
 *    } );
26
 */
27
 
28
jQuery.fn.dataTableExt.oApi.fnGetTds  = function ( oSettings, mTr )
29
{
30
    var anTds = [];
31
    var anVisibleTds = [];
32
    var iCorrector = 0;
33
    var nTd, iColumn, iColumns;
34
 
35
    /* Take either a TR node or aoData index as the mTr property */
36
    var iRow = (typeof mTr == 'object') ?
37
        oSettings.oApi._fnNodeToDataIndex(oSettings, mTr) : mTr;
38
    var nTr = oSettings.aoData[iRow].nTr;
39
 
40
    /* Get an array of the visible TD elements */
41
    for ( iColumn=0, iColumns=nTr.childNodes.length ; iColumn<iColumns ; iColumn++ )
42
    {
43
        nTd = nTr.childNodes[iColumn];
44
        if ( nTd.nodeName.toUpperCase() == "TD" )
45
        {
46
            anVisibleTds.push( nTd );
47
        }
48
    }
49
 
50
    /* Construct and array of the combined elements */
51
    for ( iColumn=0, iColumns=oSettings.aoColumns.length ; iColumn<iColumns ; iColumn++ )
52
    {
53
        if ( oSettings.aoColumns[iColumn].bVisible )
54
        {
55
            anTds.push( anVisibleTds[iColumn-iCorrector] );
56
        }
57
        else
58
        {
59
            anTds.push( oSettings.aoData[iRow]._anHidden[iColumn] );
60
            iCorrector++;
61
        }
62
    }
63
 
64
    return anTds;
65
};