From 404f049976be20e1ef377182c68c21a27ee833ca Mon Sep 17 00:00:00 2001 From: globalinnovation Date: Thu, 1 Aug 2013 12:00:56 -0300 Subject: [PATCH 1/3] Update fnAddTr.js - Fix - Showing invisible columns Showing not visible columns and returning the result of fnAddData, also fixes the problem described at https://github.com/DataTables/Plugins/pull/24 --- api/fnAddTr.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/api/fnAddTr.js b/api/fnAddTr.js index 78f4eec..6a1ab52 100644 --- a/api/fnAddTr.js +++ b/api/fnAddTr.js @@ -23,11 +23,21 @@ $.fn.dataTableExt.oApi.fnAddTr = function ( oSettings, nTr, bRedraw ) { } var aData = []; + var aInvisible = []; for ( var i=0 ; i= 0 ; i-- ) + { + nTds[aInvisible[i]].remove(); + } + /* Add the data and then replace DataTable's generated TR with ours */ var iIndex = this.oApi._fnAddData( oSettings, aData ); nTr._DT_RowIndex = iIndex; From 73201816cb7148f4fc75ecb354b36fb036a3b77f Mon Sep 17 00:00:00 2001 From: globalinnovation Date: Thu, 1 Aug 2013 13:06:33 -0300 Subject: [PATCH 3/3] Update fnAddTr.js - Fix - Showing invisible columns Showing not visible columns and returning the result of fnAddData, now using the actual TR. Also fixes the problem described at [#24](https://github.com/DataTables/Plugins/pull/24): > Okay - I agree - there is an issue here. This pull request isn't quite the right fix for the issue, so I'll not pull it in, and I'm not going to look at it myself as it should be addressed in 1.10 - but yes, there is an issue with this existing plug-in that if yourself or anyone else wishes to fix, whereby the added TR is kept, then I'll happily pull it in. > > Good to hear that the plug-in works for you though :-) And [#26](https://github.com/DataTables/Plugins/pull/26): >I'm afraid this still isn't quite right - it needs to put the hidden cell nodes into an array like fnSetColumnVis does so they can be readied in future: https://github.com/DataTables/DataTables/blob/master/media/src/api/api.methods.js#L1097 --- api/fnAddTr.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/api/fnAddTr.js b/api/fnAddTr.js index 6a1ab52..503c74d 100644 --- a/api/fnAddTr.js +++ b/api/fnAddTr.js @@ -14,14 +14,14 @@ $.fn.dataTableExt.oApi.fnAddTr = function ( oSettings, nTr, bRedraw ) { { bRedraw = true; } - + var nTds = nTr.getElementsByTagName('td'); if ( nTds.length != oSettings.aoColumns.length ) { alert( 'Warning: not adding new TR - columns and TD elements must match' ); return; } - + var aData = []; var aInvisible = []; for ( var i=0 ; i= 0 ; i-- ) - { - nTds[aInvisible[i]].remove(); - } /* Add the data and then replace DataTable's generated TR with ours */ var iIndex = this.oApi._fnAddData( oSettings, aData ); nTr._DT_RowIndex = iIndex; oSettings.aoData[ iIndex ].nTr = nTr; - + oSettings.aiDisplay = oSettings.aiDisplayMaster.slice(); - + + // Hidding invisible columns + for ( var i = (aInvisible.length - 1) ; i >= 0 ; i-- ) + { + oSettings.aoData[iIndex]._anHidden[ i ] = nTds[aInvisible[i]]; + nTr.removeChild( nTds[aInvisible[i]] ); + } + + // Redraw if ( bRedraw ) { this.oApi._fnReDraw( oSettings );