diff --git a/media/js/jquery.dataTables.js b/media/js/jquery.dataTables.js index d2acdc92..e195373c 100644 --- a/media/js/jquery.dataTables.js +++ b/media/js/jquery.dataTables.js @@ -4482,7 +4482,7 @@ iColumn, iColumns, oData, sNodeName, iStart=0, iEnd=iRows; /* Allow the collection to be limited to just one row */ - if ( iIndividualRow ) + if ( iIndividualRow !== undefined ) { iStart = iIndividualRow; iEnd = iIndividualRow+1; @@ -5503,7 +5503,9 @@ * @param {node} nTr The table row to 'open' * @param {string|node|jQuery} mHtml The HTML to put into the row * @param {string} sClass Class to give the new TD cell - * @returns {node} The row opened + * @returns {node} The row opened. Note that if the table row passed in as the + * first parameter, is not found in the table, this method will silently + * return. * * @example * $(document).ready(function() { @@ -5525,6 +5527,13 @@ { /* Find settings from table node */ var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] ); + + /* Check that the row given is in the table */ + var nTableRows = _fnGetTrNodes( oSettings ); + if ( $.inArray(nTr, nTableRows) === -1 ) + { + return; + } /* the old open one if there is one */ this.fnClose( nTr ); @@ -5546,7 +5555,7 @@ /* If the nTr isn't on the page at the moment - then we don't insert at the moment */ var nTrs = $('tr', oSettings.nTBody); - if ( $.inArray(nTr, nTrs) != -1 ) + if ( $.inArray(nTr, nTrs) != -1 ) { $(nNewRow).insertAfter(nTr); } diff --git a/media/src/api/api.methods.js b/media/src/api/api.methods.js index d9572906..08371d07 100644 --- a/media/src/api/api.methods.js +++ b/media/src/api/api.methods.js @@ -762,7 +762,9 @@ this.fnIsOpen = function( nTr ) * @param {node} nTr The table row to 'open' * @param {string|node|jQuery} mHtml The HTML to put into the row * @param {string} sClass Class to give the new TD cell - * @returns {node} The row opened + * @returns {node} The row opened. Note that if the table row passed in as the + * first parameter, is not found in the table, this method will silently + * return. * * @example * $(document).ready(function() { @@ -784,6 +786,13 @@ this.fnOpen = function( nTr, mHtml, sClass ) { /* Find settings from table node */ var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] ); + + /* Check that the row given is in the table */ + var nTableRows = _fnGetTrNodes( oSettings ); + if ( $.inArray(nTr, nTableRows) === -1 ) + { + return; + } /* the old open one if there is one */ this.fnClose( nTr ); @@ -805,7 +814,7 @@ this.fnOpen = function( nTr, mHtml, sClass ) /* If the nTr isn't on the page at the moment - then we don't insert at the moment */ var nTrs = $('tr', oSettings.nTBody); - if ( $.inArray(nTr, nTrs) != -1 ) + if ( $.inArray(nTr, nTrs) != -1 ) { $(nNewRow).insertAfter(nTr); }