| 4 |
lars |
1 |
/**
|
|
|
2 |
* This plug-in will take a `dt-tag tr` element and alter the table's paging
|
|
|
3 |
* to make that `dt-tag tr` element (i.e. that row) visible.
|
|
|
4 |
*
|
|
|
5 |
* @name fnDisplayRow
|
|
|
6 |
* @summary Shift the table's paging to display a given `dt-tag tr` element
|
|
|
7 |
* @author [Allan Jardine](http://sprymedia.co.uk)
|
|
|
8 |
*
|
|
|
9 |
* @param {node} nRow Row to display
|
|
|
10 |
*
|
|
|
11 |
* @example
|
|
|
12 |
* // Display the 21st row in the table
|
|
|
13 |
* var table = $('#example').dataTable();
|
|
|
14 |
* table.fnDisplayRow( table.fnGetNodes()[20] );
|
|
|
15 |
*/
|
|
|
16 |
|
|
|
17 |
jQuery.fn.dataTableExt.oApi.fnDisplayRow = function ( oSettings, nRow )
|
|
|
18 |
{
|
|
|
19 |
// Account for the "display" all case - row is already displayed
|
|
|
20 |
if ( oSettings._iDisplayLength == -1 )
|
|
|
21 |
{
|
|
|
22 |
return;
|
|
|
23 |
}
|
|
|
24 |
|
|
|
25 |
// Find the node in the table
|
|
|
26 |
var iPos = -1;
|
|
|
27 |
for( var i=0, iLen=oSettings.aiDisplay.length ; i<iLen ; i++ )
|
|
|
28 |
{
|
|
|
29 |
if( oSettings.aoData[ oSettings.aiDisplay[i] ].nTr == nRow )
|
|
|
30 |
{
|
|
|
31 |
iPos = i;
|
|
|
32 |
break;
|
|
|
33 |
}
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
// Alter the start point of the paging display
|
|
|
37 |
if( iPos >= 0 )
|
|
|
38 |
{
|
|
|
39 |
oSettings._iDisplayStart = ( Math.floor(i / oSettings._iDisplayLength) ) * oSettings._iDisplayLength;
|
|
|
40 |
if ( this.oApi._fnCalculateEnd ) {
|
|
|
41 |
this.oApi._fnCalculateEnd( oSettings );
|
|
|
42 |
}
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
this.oApi._fnDraw( oSettings );
|
|
|
46 |
};
|