var processBaseMeshDatatableExportAction = function (self, e, dt, button, config) { if (button[0].className.indexOf('buttons-excel') >= 0) { if ($.fn.dataTable.ext.buttons.excelHtml5.available(dt, config)) { $.fn.dataTable.ext.buttons.excelHtml5.action.call(self, e, dt, button, config); } else { $.fn.dataTable.ext.buttons.excelFlash.action.call(self, e, dt, button, config); } } else if (button[0].className.indexOf('buttons-copy') >= 0) { $.fn.dataTable.ext.buttons.copyHtml5.action(e, dt, button, config); } else if (button[0].className.indexOf('buttons-csv') >= 0) { if ($.fn.dataTable.ext.buttons.csvHtml5.available( dt, config )) { $.fn.dataTable.ext.buttons.csvHtml5.action(e, dt, button, config); } else { $.fn.dataTable.ext.buttons.csvFlash.action(e, dt, button, config); } } else if (button[0].className.indexOf('buttons-pdf') >= 0) { if ($.fn.dataTable.ext.buttons.pdfHtml5.available(dt, config)) { $.fn.dataTable.ext.buttons.pdfHtml5.action(e, dt, button, config); } else { $.fn.dataTable.ext.buttons.pdfFlash.action(e, dt, button, config); } } else if (button[0].className.indexOf('buttons-print') >= 0) { $.fn.dataTable.ext.buttons.print.action(e, dt, button, config); } }; var startBaseMeshDatatableExportAction = function (e, dt, button, config) { var self = this; var oldStart = dt.settings()[0]._iDisplayStart; //console.log("hello"); dt.one('preXhr', function (e, s, data) { // Just this once, load all data from the server... data.start = 0; data.length = 2147483647; dt.one('preDraw', function (e, settings) { // Call the original action function processBaseMeshDatatableExportAction(self, e, dt, button, config); dt.one('preXhr', function (e, s, data) { // DataTables thinks the first item displayed is index 0, but we're not drawing that. // Set the property to what it was before exporting. settings._iDisplayStart = oldStart; data.start = oldStart; }); // Reload the grid with the original page. Otherwise, API functions like table.cell(this) don't work properly. setTimeout(dt.ajax.reload, 0); // Prevent rendering of the full data to the DOM return false; }); }); // Re-query the server with the new one-time export settings dt.ajax.reload(); }; function buildMeshDatatableButtons(exportColumns) { var meshDataTableButtons = [ { extend: 'collection', text: 'Export', autoClose: true, buttons: [ { text: ' Copy', extend: 'copyHtml5', action: startBaseMeshDatatableExportAction, exportOptions: { columns: exportColumns } }, { text: ' Excel', extend: 'excelHtml5', action: startBaseMeshDatatableExportAction, exportOptions: { columns: exportColumns } }, { text: ' PDF', extend: 'pdfHtml5', action: startBaseMeshDatatableExportAction, exportOptions: { columns: exportColumns, modifier: { alignment: 'left' } } }, { text: ' CSV', extend: 'csvHtml5', action: startBaseMeshDatatableExportAction, exportOptions: { columns: exportColumns } }, { text: ' Print Shown', extend: 'print', exportOptions: { columns: exportColumns } } ] } ]; return meshDataTableButtons; }; function buildMeshDatatableButtonsNoAjax(exportColumns) { var meshDataTableButtons = [ { extend: 'collection', text: 'Export', autoClose: true, buttons: [ { text: ' Copy Shown', extend: 'copyHtml5', exportOptions: { columns: exportColumns } }, { text: ' Excel Shown', extend: 'excelHtml5', exportOptions: { columns: exportColumns } }, { text: ' PDF Shown', extend: 'pdfHtml5', exportOptions: { columns: exportColumns, modifier: { alignment: 'left' } } }, { text: ' CSV Shown', extend: 'csvHtml5', exportOptions: { columns: exportColumns } }, { text: ' Print Shown', extend: 'print', exportOptions: { columns: exportColumns } } ] } ]; return meshDataTableButtons; }; function refreshMeshDataTable(t) { var nowDataTable = $('#' + t).DataTable(); nowrefresh = 'true'; nowDataTable.draw(); } function resetDisplay() { $('.timeago').timeago(); $('[data-tooltip]').qtip({ // Grab all elements with a non-blank data-tooltip attr. style: { classes: 'qtip-jtools' }, content: { attr: 'data-tooltip' // Tell qTip2 to look inside this attr for its content } }); $("#searchboxdepricate").keyup(function (e) { var nowDataTable = $('#meshdatatable').DataTable(); //console.log("1: " + this.value); var filterV = getfilteredSearchBox(); if (filterV.length >= 3 && e.keyCode == 13) { nowDataTable.search(filterV).draw(); //console.log("1a: " + this.value); $("#jqxbutton").html('Clear Filter: ' + this.value); $("#dtclearbut").show(); $("#dtclearbutall").show(); } if (filterV == "") { //console.log("1b: " + this.value); nowDataTable.search('').draw(); $("#jqxbutton").html('Clear Filter'); $("#dtclearbut").hide(); evalClearAllButton(); } }); }; //toggles potetial advance seach row function advsearchtoggle() { var nowDataTable = $('#meshdatatable').DataTable(); $('#meshgridadvsearch').toggle(500); nowDataTable.draw(); }; //checks all columns for any filter - returns true or false function checkAnyFilter() { var nowDataTable = $('#meshdatatable').DataTable(); var mainsearchbox = getfilteredSearchBox(); if (mainsearchbox != "") { return true; }; var fullcheck = ""; //console.log("2: " + mainsearchbox); nowDataTable.columns().eq(0).each(function (colIdx) { var tfilter = (colIdx, nowDataTable.column(colIdx).search()); if (tfilter != "") { fullcheck = tfilter; return true; }; var advid = "advsearch_" + colIdx; var advserachval = document.getElementById(advid); if (advserachval != null) { tfilter = $('#' + advid).val(); if (tfilter != "") { fullcheck = tfilter; return true; }; } }); if (fullcheck != "") { return true; } else { return false; }; }; function checkAnyFilterDynamic(sourceTable) { var nowDataTable = $('#' + sourceTable).DataTable(); var mainsearchbox = getfilteredSearchBoxDynamic(sourceTable); if (mainsearchbox != "") { return true; }; var fullcheck = ""; //console.log("2: " + mainsearchbox); nowDataTable.columns().eq(0).each(function (colIdx) { var tfilter = (colIdx, nowDataTable.column(colIdx).search()); if (tfilter != "") { fullcheck = tfilter; return true; }; var advid = "advsearch_" + colIdx; var advserachval = document.getElementById(advid); if (advserachval != null) { tfilter = $('#' + advid).val(); if (tfilter != "") { fullcheck = tfilter; return true; }; } }); if (fullcheck != "") { return true; } else { return false; }; }; //determines in clear all button should be present function evalClearAllButton() { if (checkAnyFilter()) { $('#dtclearbutall').show(); } else { $('#dtclearbutall').hide(); } }; function evalClearAllButtonDynamic(sourceTable) { if (checkAnyFilterDynamic(sourceTable)) { $('#dtclearbutall' + sourceTable).show(); } else { $('#dtclearbutall' + sourceTable).hide(); } }; function getfilteredSearchBox() { var filterVal = $("#searchbox").val(); if(filterVal == null || filterVal === '') return ''; filterVal = filterVal.replace('<',''); filterVal = filterVal.replace('>',''); filterVal = filterVal.replace('?',''); filterVal = filterVal.replace('[',''); filterVal = filterVal.replace(']',''); filterVal = filterVal.replace('=',''); return filterVal; }; function getfilteredSearchBoxDynamic(sourceTable) { var filterVal = $("#searchbox" + sourceTable).val(); if(filterVal == null || filterVal === '') return ''; filterVal = filterVal.replace('<',''); filterVal = filterVal.replace('>',''); filterVal = filterVal.replace('?',''); filterVal = filterVal.replace('[',''); filterVal = filterVal.replace(']',''); filterVal = filterVal.replace('=',''); return filterVal; }; //returns number of columns in a table function getdtcolcount() { var nowDataTable = $('#meshdatatable').DataTable(); return nowDataTable.columns().nodes().length; }; function getdtcolcountDynamic(sourceTable) { var nowDataTable = $('#' + sourceTable).DataTable(); return nowDataTable.columns().nodes().length; }; //initiate search from magnifying glass click function gpwmeshsearchinit() { var nowDataTable = $('#meshdatatable').DataTable(); var mainsearchbox = getfilteredSearchBox(); //console.log("3: " + mainsearchbox); if (mainsearchbox.length >= 3) { nowDataTable.search(mainsearchbox).draw(); //console.log("3a: " + mainsearchbox); $("#jqxbutton").html('Clear Filter: ' + mainsearchbox); $("#dtclearbut").show(); $("#dtclearbutall").show(); } if (mainsearchbox == "") { //console.log("3b: " + mainsearchbox); nowDataTable.search('').draw(); $("#jqxbutton").html('Clear Filter'); $("#dtclearbut").hide(); evalClearAllButton(); } }; function gpwmeshsearchinitDynamic(sourceTable) { var nowDataTable = $('#' + sourceTable).DataTable(); var mainsearchbox = getfilteredSearchBoxDynamic(sourceTable); //console.log("3: " + mainsearchbox); if (mainsearchbox.length >= 3) { nowDataTable.search(mainsearchbox).draw(); //console.log("3a: " + mainsearchbox); $("#jqxbutton" + sourceTable).html('Clear Filter: ' + mainsearchbox); $("#dtclearbut" + sourceTable).show(); $("#dtclearbutall" + sourceTable).show(); } if (mainsearchbox == "") { //console.log("3b: " + mainsearchbox); nowDataTable.search('').draw(); $("#jqxbutton" + sourceTable).html('Clear Filter'); $("#dtclearbut" + sourceTable).hide(); evalClearAllButtonDynamic(); } }; //clears all filters function clearfiltercolall() { var nowDataTable = $('#meshdatatable').DataTable(); var theseCol = getdtcolcount(); for (var i = 0; i <= theseCol; i++) { nowDataTable.columns(i).search(''); $("#dtclearbut" + i).hide(); $("#jqxbutton" + i).html('Clear Filter'); var advid = "advsearch_" + i; var advidop = "advsearchop_" + i; var advserachval = document.getElementById(advid); if (advserachval != null) { $('#' + advid).val(''); $('#' + advidop).val(''); } } $("#dtclearbutall").hide(); $(".dtgpwfilterbutton").hide();; $("#dtclearbut").hide(); $("#jqxbutton").html('Clear Filter'); $("#searchbox").val(''); nowDataTable.search('').draw(); $(".meshgridsel").each(function (index) { var nowid = ($(this).data("id")); var elementExists = document.getElementById(nowid); if (elementExists != null) { elementExists.style.backgroundColor = "#3c8dbc"; $('#' + nowid).val(""); } }); }; function clearfiltercolallDynamic(sourceTable) { var nowDataTable = $('#' + sourceTable).DataTable(); var theseCol = getdtcolcountDynamic(sourceTable); for (var i = 0; i <= theseCol; i++) { nowDataTable.columns(i).search(''); $("#dtclearbut" + sourceTable + i).hide(); $("#jqxbutton" + sourceTable + i).html('Clear Filter'); var advid = "advsearch_" + sourceTable + i; var advidop = "advsearchop_" + sourceTable + i; var advserachval = document.getElementById(advid); if (advserachval != null) { $('#' + advid).val(''); $('#' + advidop).val(''); } } $("#dtclearbutall" + sourceTable).hide(); $(".dtgpwfilterbutton" + sourceTable).hide();; $("#dtclearbut" + sourceTable).hide(); $("#jqxbutton" + sourceTable).html('Clear Filter'); $("#searchbox" + sourceTable).val(''); nowDataTable.search('').draw(); $(".meshgridsel" + sourceTable).each(function (index) { var nowid = ($(this).data("id")); var elementExists = document.getElementById(nowid); if (elementExists != null) { elementExists.style.backgroundColor = "#3c8dbc"; $('#' + nowid).val(""); } }); }; //clear filter for a single advance serahc column function clearfilteradv(col) { var nowDataTable = $('#meshdatatable').DataTable(); $('#advsearch_' + col).val(''); $('#advsearchop_' + col).val(''); $('#advclearbut_' + col).hide(); nowDataTable.columns(col).search(''); nowDataTable.draw(); evalClearAllButton(); }; function clearfilteradvDynamic(col, sourceTable) { var nowDataTable = $('#' + sourceTable).DataTable(); $('#advsearch_' + sourceTable + col).val(''); $('#advsearchop_' + sourceTable + col).val(''); $('#advclearbut_' + sourceTable + col).hide(); nowDataTable.columns(col).search(''); nowDataTable.draw(); evalClearAllButtonDynamic(sourceTable); }; //clear filter for a single table column function clearfiltercol(col) { var nowDataTable = $('#meshdatatable').DataTable(); nowDataTable.columns(col).search(''); nowDataTable.draw(); $(".meshgridsel").each(function (index) { var nowid = ($(this).data("id")); var nowcol = ($(this).data("col")); }); $("#dtclearbut" + col).hide(); $("#jqxbutton" + col).html('Clear Filter'); evalClearAllButton(); }; function clearfiltercolDynamic(col, sourceTable) { var nowDataTable = $('#' + sourceTable).DataTable(); nowDataTable.columns(col).search(''); nowDataTable.draw(); $(".meshgridsel" + sourceTable).each(function (index) { var nowid = ($(this).data("id")); var nowcol = ($(this).data("col")); }); $("#dtclearbut" + sourceTable + col).hide(); $("#jqxbutton" + sourceTable + col).html('Clear Filter'); evalClearAllButtonDynamic(sourceTable); }; //watches pulldowns for select values $('.meshgridsel').on('change', function () { var nowcol = ($(this).data("col")); var nowid = ($(this).data("id")); var nowtitle = ($(this).data("title")); //var usetitle = this.text(); var usetitle = $(this).find("option:selected").text(); if (usetitle != "" && usetitle.toLowerCase() == "true") { usetitle = nowtitlec } else if (usetitle != "" && usetitle.toLowerCase() == "false") { usetitle = nowtitle } var nowDataTable = $('#meshdatatable').DataTable(); nowDataTable.columns(nowcol).search(this.value).draw(); if (this.value != "") { document.getElementById(nowid).style.backgroundColor = "#367fa9"; } else { document.getElementById(nowid).style.backgroundColor = "#3c8dbc"; } if (this.value != "") { $("#jqxbutton" + nowcol).html('Clear Filter: ' + usetitle); $('#dtclearbut' + nowcol).show(); $('#dtclearbutall').show(); } else { $("#jqxbutton" + nowcol).html('Clear Filter'); $('#dtclearbut' + nowcol).hide(); } evalClearAllButton(); }); //Invokes advance search on a single column $('.advsearchbut').click( function () { var nowcol = ($(this).data("col")); //console.log(nowcol); var nowv = ($('#advsearch_' + nowcol).val()); //console.log(nowv); if (nowv == "") { nowv = $('#advsearch_' + nowcol).find("option:selected").val(); //console.log("op:" + nowv); } if (nowv != "") { $('#advclearbut_' + nowcol).show(); } var nowDataTable = $('#meshdatatable').DataTable(); nowDataTable.ajax.reload(); nowDataTable.draw(); evalClearAllButton(); }); //searches a specific column where value contains search value function findtypecol(typename, col, showname) { var nowDataTable = $('#meshdatatable').DataTable(); nowDataTable.columns(col).search(typename).draw(); $("#jqxbutton" + col).html('Clear Filter: ' + showname); $('#dtclearbut' + col).show(); evalClearAllButton(); }; function findtypecolDynamic(typename, col, showname) { var sourceTable='meshdatatable'; var nowDataTable = $('#' + sourceTable).DataTable(); nowDataTable.columns(col).search(typename).draw(); $("#jqxbutton" + sourceTable + col).html('Clear Filter: ' + showname); $('#dtclearbut' + sourceTable + col).show(); evalClearAllButtonDynamic(sourceTable); }; function findtypecolDynamic(typename, col, showname, sourceTable) { var nowDataTable = $('#' + sourceTable).DataTable(); nowDataTable.columns(col).search(typename).draw(); $("#jqxbutton" + sourceTable + col).html('Clear Filter: ' + showname); $('#dtclearbut' + sourceTable + col).show(); evalClearAllButtonDynamic(sourceTable); }; //stops advanced seaqrch from sorting function stopPropagation(evt) { if (evt.stopPropagation !== undefined) { evt.stopPropagation(); } else { evt.cancelBubble = true; } }; function gpwdrawdtsearchclearbuttons(col) { for (var j = 0; j <= col; j++) { $("div.gpwclear" + j).html('
'); } $("div.gpwclearall") .html(''); $("div.gpwclear") .html(''); }; function gpwdrawdtsearchclearbuttonsDynamic(col, sourceTable) { for (var j = 0; j <= col; j++) { $("div.gpwclear" + sourceTable + j).html(''); } $("div.gpwclearall" + sourceTable) .html(''); $("div.gpwclear" + sourceTable) .html(''); }; function gpwmeshstddtclear() { var nowDataTable = $('#meshdatatable').DataTable(); nowDataTable.search('').draw(); $("#dtclearbut").hide(); $("#jqxbutton").html('Clear Filter'); $("#searchbox").val(''); evalClearAllButton(); }; function gpwmeshstddtclearDynamic(sourceTable) { var nowDataTable = $('#' + sourceTable).DataTable(); nowDataTable.search('').draw(); $("#dtclearbut" + sourceTable).hide(); $("#jqxbutton" + sourceTable).html('Clear Filter'); $("#searchbox" + sourceTable).val(''); evalClearAllButton(); }; function findtype(typename) { var nowDataTable = $('#meshdatatable').DataTable(); nowDataTable.search(typename).draw(); $("#searchbox").val(''); $("#jqxbutton").html('Clear Filter: ' + typename); $("#dtclearbut").show(); }; function findtypeDynamic(typename, sourceTable) { var nowDataTable = $('#' + sourceTable).DataTable(); nowDataTable.search(typename).draw(); $("#searchbox" + sourceTable).val(''); $("#jqxbutton" + sourceTable).html('Clear Filter: ' + typename); $("#dtclearbut" + sourceTable).show(); }; function gpwmeshsearchinit() { var nowDataTable = $('#meshdatatable').DataTable(); var mainsearchbox = getfilteredSearchBox(); //console.log("4: " + mainsearchbox); if (mainsearchbox.length >= 3) { //console.log("4a: " + mainsearchbox); nowDataTable.search(mainsearchbox).draw(); $("#jqxbutton").html('Clear Filter: ' + mainsearchbox); $("#dtclearbut").show(); $("#dtclearbutall").show(); } if (mainsearchbox == "") { //console.log("4b: " + mainsearchbox); nowDataTable.search('').draw(); $("#jqxbutton").html('Clear Filter'); $("#dtclearbut").hide(); evalClearAllButton(); } }; function gpwmeshsearchinitDynamic(sourceTable) { var nowDataTable = $('#' + sourceTable).DataTable(); var mainsearchbox = getfilteredSearchBoxDynamic(sourceTable); //console.log("4: " + mainsearchbox); if (mainsearchbox.length >= 3) { //console.log("4a: " + mainsearchbox); nowDataTable.search(mainsearchbox).draw(); $("#jqxbutton" + sourceTable).html('Clear Filter: ' + mainsearchbox); $("#dtclearbut" + sourceTable).show(); $("#dtclearbutall" + sourceTable).show(); } if (mainsearchbox == "") { //console.log("4b: " + mainsearchbox); nowDataTable.search('').draw(); $("#jqxbutton" + sourceTable).html('Clear Filter'); $("#dtclearbut" + sourceTable).hide(); evalClearAllButtonDynamic(sourceTable); } }; function gpwmeshsearchdynamic() { var nowDataTable = $('#meshdatatable').DataTable(); var mainsearchbox = getfilteredSearchBox(); //console.log("5: " + mainsearchbox); if (mainsearchbox.length >= 3) { //console.log("5a: " + mainsearchbox); nowDataTable.search(mainsearchbox).draw(); $("#jqxbutton").html('Clear Filter: ' + mainsearchbox); $("#dtclearbut").show(); $("#dtclearbutall").show(); } else if (mainsearchbox == "") { //console.log("5b: " + mainsearchbox); nowDataTable.search('').draw(); $("#jqxbutton").html('Clear Filter'); $("#dtclearbut").hide(); evalClearAllButton(); } }; function gpwmeshsearchdynamicDynamic(sourceTable) { var nowDataTable = $('#' + sourceTable).DataTable(); var mainsearchbox = getfilteredSearchBoxDynamic(sourceTable); //console.log("5: " + mainsearchbox); if (mainsearchbox.length >= 3) { //console.log("5a: " + mainsearchbox); nowDataTable.search(mainsearchbox).draw(); $("#jqxbutton" + sourceTable).html('Clear Filter: ' + mainsearchbox); $("#dtclearbut" + sourceTable).show(); $("#dtclearbutall" + sourceTable).show(); } else if (mainsearchbox == "") { //console.log("5b: " + mainsearchbox); nowDataTable.search('').draw(); $("#jqxbutton" + sourceTable).html('Clear Filter'); $("#dtclearbut" + sourceTable).hide(); evalClearAllButton(); } }; function gpwmeshsearchonenter(e) { var nowDataTable = $('#meshdatatable').DataTable(); var mainsearchbox = getfilteredSearchBox(); //console.log("6: " + mainsearchbox); if (e.keyCode == 13) { //console.log("6a: " + mainsearchbox); if (mainsearchbox.length >= 3) { //console.log("6b: " + mainsearchbox); nowDataTable.search(mainsearchbox).draw(); $("#jqxbutton").html('Clear Filter: ' + mainsearchbox); $("#dtclearbut").show(); $("#dtclearbutall").show(); } else if (mainsearchbox == "") { //console.log("6c: " + mainsearchbox); nowDataTable.search('').draw(); $("#jqxbutton").html('Clear Filter'); $("#dtclearbut").hide(); evalClearAllButton(); } } }; function gpwmeshsearchonenterDynamic(e, sourceTable) { var nowDataTable = $('#' + sourceTable).DataTable(); var mainsearchbox = getfilteredSearchBoxDynamic(sourceTable); //console.log("6: " + mainsearchbox); if (e.keyCode == 13) { //console.log("6a: " + mainsearchbox); if (mainsearchbox.length >= 3) { //console.log("6b: " + mainsearchbox); nowDataTable.search(mainsearchbox).draw(); $("#jqxbutton" + sourceTable).html('Clear Filter: ' + mainsearchbox); $("#dtclearbut" + sourceTable).show(); $("#dtclearbutall" + sourceTable).show(); } else if (mainsearchbox == "") { //console.log("6c: " + mainsearchbox); nowDataTable.search('').draw(); $("#jqxbutton" + sourceTable).html('Clear Filter'); $("#dtclearbut" + sourceTable).hide(); evalClearAllButtonDynamic(sourceTable); } } }; function gpwmeshholdsearchdivs(col) { var retsearchdiv = ""; for (var i = 0; i <= col; i++) { retsearchdiv = retsearchdiv + '<"gpwclear' + i + '">'; } return retsearchdiv; } function gpwmeshDataTableSetsDom(col, sourceTable, search, padge, countit) { search = search != null ? search : 1; padge = padge != null ? padge : 1; countit = countit != null ? countit : 1; retsearchdiv = '<"customMeshDtgSearch' + sourceTable + '"><"tdright"><"clear">'; var pdgeit = "i"; if(padge == 0) { pdgeit = ""; } if(countit == 0) { pdgeit = ""; } if(search == 1) { retsearchdiv = retsearchdiv + '<"tdleft"' + pdgeit + '><"tdright"f><"gpwsearch' + sourceTable + '"><"clear"><<"gpwclearall' + sourceTable + '"><"gpwclear' + sourceTable + '">'; } else{ retsearchdiv = retsearchdiv + '<"tdleft"' + pdgeit + '><"tdright"><"clear"><<"gpwclearall' + sourceTable + '"><"gpwclear' + sourceTable + '">'; } for (var i = 0; i <= col; i++) { retsearchdiv = retsearchdiv + '<"gpwclear' + sourceTable + i + '">'; } if(padge == 1) { retsearchdiv = retsearchdiv + '><"tdright"><"clear">