| 8 |
lars |
1 |
/**
|
|
|
2 |
* Get a `dt-tag td` node from a row, taking into account column visibility.
|
|
|
3 |
* While getting a `dt-tag td` node is easy when it is visible on the page by
|
|
|
4 |
* using normal DOM methods, jQuery or whatever, it becomes a lot more
|
|
|
5 |
* complicated when taking into account hidden rows and columns. This function
|
|
|
6 |
* can be used to overcome these difficulties.
|
|
|
7 |
*
|
|
|
8 |
* DataTables 1.10+'s new API provides the `dt-api cell()` and `dt-api cells()`
|
|
|
9 |
* methods which are preferable for use over this method. As such this method is
|
|
|
10 |
* marked deprecated, but is available for use with legacy version of
|
|
|
11 |
* DataTables. Please use the new API if you are used DataTables 1.10 or newer.
|
|
|
12 |
*
|
|
|
13 |
* @name fnGetTd
|
|
|
14 |
* @summary Get the `dt-tag td` element for a cell.
|
|
|
15 |
* @author [Allan Jardine](http://sprymedia.co.uk)
|
|
|
16 |
* @deprecated
|
|
|
17 |
*
|
|
|
18 |
* @param {node} mTr `dt-tag tr` element to get the `dt-tag td` of
|
|
|
19 |
* @param {integer} iTd Column index to get the node of
|
|
|
20 |
* @param {boolean} bVisOnly Consider visible columns only
|
|
|
21 |
* @returns {node} `dt-tag td` element in question
|
|
|
22 |
*
|
|
|
23 |
* @example
|
|
|
24 |
* $(document).ready(function() {
|
|
|
25 |
* var table = $('#example').dataTable();
|
|
|
26 |
*
|
|
|
27 |
* // Sort in the order that was origially in the HTML
|
|
|
28 |
* var nTd = table.fnGetTd( $('#example tbody tr:eq(1)')[0], 1 );
|
|
|
29 |
* console.log( nTd );
|
|
|
30 |
* } );
|
|
|
31 |
*/
|
|
|
32 |
|
|
|
33 |
jQuery.fn.dataTableExt.oApi.fnGetTd = function ( oSettings, mTr, iTd, bVisOnly )
|
|
|
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 |
|
|
|
39 |
if ( typeof bVisOnly == 'undefined' && !bVisOnly )
|
|
|
40 |
{
|
|
|
41 |
/* Looking at both visible and hidden TD elements - convert to visible index, if not present
|
|
|
42 |
* then it must be hidden. Return as appropriate
|
|
|
43 |
*/
|
|
|
44 |
var iCalcVis = oSettings.oApi._fnColumnIndexToVisible( oSettings, iTd );
|
|
|
45 |
if ( iCalcVis !== null )
|
|
|
46 |
{
|
|
|
47 |
return oSettings.aoData[ iRow ].nTr.getElementsByTagName('td')[ iCalcVis ];
|
|
|
48 |
}
|
|
|
49 |
else
|
|
|
50 |
{
|
|
|
51 |
return oSettings.aoData[ iRow ]._anHidden[ iTd ];
|
|
|
52 |
}
|
|
|
53 |
}
|
|
|
54 |
else
|
|
|
55 |
{
|
|
|
56 |
/* Only looking at visible TD elements, so just use getElements... */
|
|
|
57 |
return oSettings.aoData[ iRow ].nTr.getElementsByTagName('td')[ iTd ];
|
|
|
58 |
}
|
|
|
59 |
};
|