1
0
mirror of https://github.com/DataTables/DataTables.git synced 2025-02-27 00:54:15 +01:00

New: New API method: fnIsOpen - to work with fnOpen and fnClose, allowing a quick check to see if the row is currently open or not.

This commit is contained in:
Allan Jardine 2011-12-06 11:05:58 +00:00
parent 8795d97194
commit c6d1dfd929
2 changed files with 92 additions and 28 deletions

View File

@ -4753,13 +4753,11 @@
*
* // 'open' an information row when a row is clicked on
* $('#example tbody tr').click( function () {
* var that = this;
* oTable.fnOpen( this, "Temporary row opened", "info_row" );
*
* // Then when the info row is clicked upon - close it
* $('#example .info_row').click( function () {
* oTable.fnClose(that);
* } );
* if ( oTable.fnIsOpen(this) ) {
* oTable.fnClose( this );
* } else {
* oTable.fnOpen( this, "Temporary row opened", "info_row" );
* }
* } );
*
* oTable = $('#example').dataTable();
@ -5209,6 +5207,42 @@
};
/**
* Check to see if a row is 'open' or not.
* @param {node} nTr the table row to check
* @returns {boolean} true if the row is currently open, false otherwise
*
* @example
* $(document).ready(function() {
* var oTable;
*
* // 'open' an information row when a row is clicked on
* $('#example tbody tr').click( function () {
* if ( oTable.fnIsOpen(this) ) {
* oTable.fnClose( this );
* } else {
* oTable.fnOpen( this, "Temporary row opened", "info_row" );
* }
* } );
*
* oTable = $('#example').dataTable();
* } );
*/
this.fnIsOpen = function( nTr )
{
var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] );
for ( var i=0 ; i<oSettings.aoOpenRows.length ; i++ )
{
if ( oSettings.aoOpenRows[i].nParent == nTr )
{
return true;
}
}
return false;
};
/**
* This function will place a new row directly after a row which is currently
* on display on the page, with the HTML contents that is passed into the
@ -5225,13 +5259,11 @@
*
* // 'open' an information row when a row is clicked on
* $('#example tbody tr').click( function () {
* var that = this;
* oTable.fnOpen( this, "Temporary row opened", "info_row" );
*
* // Then when the info row is clicked upon - close it
* $('#example .info_row').click( function () {
* oTable.fnClose(that);
* } );
* if ( oTable.fnIsOpen(this) ) {
* oTable.fnClose( this );
* } else {
* oTable.fnOpen( this, "Temporary row opened", "info_row" );
* }
* } );
*
* oTable = $('#example').dataTable();

View File

@ -169,13 +169,11 @@ this.fnClearTable = function( bRedraw )
*
* // 'open' an information row when a row is clicked on
* $('#example tbody tr').click( function () {
* var that = this;
* oTable.fnOpen( this, "Temporary row opened", "info_row" );
*
* // Then when the info row is clicked upon - close it
* $('#example .info_row').click( function () {
* oTable.fnClose(that);
* } );
* if ( oTable.fnIsOpen(this) ) {
* oTable.fnClose( this );
* } else {
* oTable.fnOpen( this, "Temporary row opened", "info_row" );
* }
* } );
*
* oTable = $('#example').dataTable();
@ -625,6 +623,42 @@ this.fnGetPosition = function( nNode )
};
/**
* Check to see if a row is 'open' or not.
* @param {node} nTr the table row to check
* @returns {boolean} true if the row is currently open, false otherwise
*
* @example
* $(document).ready(function() {
* var oTable;
*
* // 'open' an information row when a row is clicked on
* $('#example tbody tr').click( function () {
* if ( oTable.fnIsOpen(this) ) {
* oTable.fnClose( this );
* } else {
* oTable.fnOpen( this, "Temporary row opened", "info_row" );
* }
* } );
*
* oTable = $('#example').dataTable();
* } );
*/
this.fnIsOpen = function( nTr )
{
var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] );
for ( var i=0 ; i<oSettings.aoOpenRows.length ; i++ )
{
if ( oSettings.aoOpenRows[i].nParent == nTr )
{
return true;
}
}
return false;
};
/**
* This function will place a new row directly after a row which is currently
* on display on the page, with the HTML contents that is passed into the
@ -641,13 +675,11 @@ this.fnGetPosition = function( nNode )
*
* // 'open' an information row when a row is clicked on
* $('#example tbody tr').click( function () {
* var that = this;
* oTable.fnOpen( this, "Temporary row opened", "info_row" );
*
* // Then when the info row is clicked upon - close it
* $('#example .info_row').click( function () {
* oTable.fnClose(that);
* } );
* if ( oTable.fnIsOpen(this) ) {
* oTable.fnClose( this );
* } else {
* oTable.fnOpen( this, "Temporary row opened", "info_row" );
* }
* } );
*
* oTable = $('#example').dataTable();