From ffb77df94f14f65c5f1d1516cb6e92389f1442d3 Mon Sep 17 00:00:00 2001 From: Paul Zepernick Date: Fri, 30 Jan 2015 14:30:53 -0500 Subject: [PATCH] Bug Fix: Not putting in empty cells for hidden columns. The row did not carry the right number of cells. Bug Fix: Added a listener for columns being hidden so that the plugin could adjust the search bar at the time of hiding. --- .../columnSearchField/dataTables.colsearch.js | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/features/columnSearchField/dataTables.colsearch.js b/features/columnSearchField/dataTables.colsearch.js index b052cec..babdabe 100644 --- a/features/columnSearchField/dataTables.colsearch.js +++ b/features/columnSearchField/dataTables.colsearch.js @@ -120,15 +120,21 @@ THE SOFTWARE. this.dtsettings = dtsettings; //console.log(dtsettings); - var tr = $(""); + var tr = $("").addClass("dataTable_colSearchBar"); var cols = dtsettings.aoColumns; var colLen = cols.length; //console.info(cols); for(var i = 0; i < colLen; i++) { - if(cols[i].bVisible === false || cols[i].bSearchable === false) { + if(cols[i].bVisible === false) { continue; } + + if(cols[i].bSearchable === false) { + tr.append($("")); + continue; + } + var name = cols[i].data || cols[i].mData; var input = this._getSearchCtrl(name, i).addClass(this.getOptions().controlClass); var td = $("").append(input); @@ -151,6 +157,11 @@ THE SOFTWARE. parent.prepend(tr); + //listen for columns being hidden and make sure we hide the column in the search bar too + $(dtapi.table().node()).on("column-visibility.dt", function(e, settings, column, state) { + tr.children().eq(column).toggle(state); + }); + }, //private method to build the text or select box for the searching @@ -232,6 +243,9 @@ THE SOFTWARE. $.fn.dataTable.DtServerColSearch = DtServerColSearch; $.fn.DataTable.DtServerColSearch = DtServerColSearch; + + + return DtServerColSearch; }; @@ -249,4 +263,6 @@ THE SOFTWARE. factory( jQuery, jQuery.fn.dataTable ); } + + })(window, document); \ No newline at end of file