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