From 6d67d8ecf5e268076c82e98e49c67b73beb37eb8 Mon Sep 17 00:00:00 2001 From: Kartik Visweswaran Date: Sun, 9 Sep 2018 23:44:24 +0530 Subject: [PATCH] Fix #820: Ability to strip HTML tags for columns from export --- CHANGE.md | 3 ++- src/ColumnTrait.php | 9 +++++++ src/assets/css/kv-grid-expand.css | 2 +- src/assets/css/kv-grid-expand.min.css | 2 +- src/assets/css/kv-grid.css | 2 +- src/assets/css/kv-grid.min.css | 2 +- src/assets/js/kv-grid-checkbox.js | 4 +-- src/assets/js/kv-grid-checkbox.min.js | 4 +-- src/assets/js/kv-grid-editable.js | 4 +-- src/assets/js/kv-grid-editable.min.js | 4 +-- src/assets/js/kv-grid-expand.js | 4 +-- src/assets/js/kv-grid-expand.min.js | 4 +-- src/assets/js/kv-grid-export.js | 38 +++++++++++---------------- src/assets/js/kv-grid-export.min.js | 7 ++--- src/assets/js/kv-grid-group.js | 4 +-- src/assets/js/kv-grid-group.min.js | 4 +-- src/assets/js/kv-grid-radio.js | 4 +-- src/assets/js/kv-grid-radio.min.js | 4 +-- src/assets/js/kv-grid-toggle.js | 4 +-- src/assets/js/kv-grid-toggle.min.js | 4 +-- 20 files changed, 59 insertions(+), 54 deletions(-) diff --git a/CHANGE.md b/CHANGE.md index 6b72f3a4..a44e1fe2 100755 --- a/CHANGE.md +++ b/CHANGE.md @@ -3,8 +3,9 @@ Change Log: `yii2-grid` ## Version 3.2.0 -**Date:** _under development_ +**Date:** 09-Sep-2018 +- (enh #820): Ability to strip HTML tags for columns from export. - (enh #819): Enhance grid export generation for PJAX grids (correct timestamp). - (enh #818): Correct PDF Export Generation response. - (enh #816): Fix typo in check if has `xlFormat`. diff --git a/src/ColumnTrait.php b/src/ColumnTrait.php index 67e10679..ed6a5fb9 100644 --- a/src/ColumnTrait.php +++ b/src/ColumnTrait.php @@ -49,6 +49,12 @@ trait ColumnTrait */ public $hiddenFromExport; + /** + * @var boolean whether to strip HTML tags from the column during export. This can be useful for column data that + * is mainly a hyperlink or contains HTML markup that are not needed for display at export. Defaults to `false`. + */ + public $stripTagsFromExport = false; + /** * @var boolean whether to force no wrapping on all table cells in the column * @see http://www.w3schools.com/cssref/pr_text_white-space.asp @@ -386,6 +392,9 @@ protected function checkValidFilters() */ protected function parseVisibility() { + if ($this->stripTagsFromExport) { + Html::addCssClass($this->options, 'strip-tags-export'); + } if ($this->hidden === true) { Html::addCssClass($this->filterOptions, 'kv-grid-hide'); Html::addCssClass($this->headerOptions, 'kv-grid-hide'); diff --git a/src/assets/css/kv-grid-expand.css b/src/assets/css/kv-grid-expand.css index b94a8ede..a54a8a03 100644 --- a/src/assets/css/kv-grid-expand.css +++ b/src/assets/css/kv-grid-expand.css @@ -2,7 +2,7 @@ * @package yii2-grid * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2018 - * @version 3.1.8 + * @version 3.2.0 * * Gridview ExpandRowColumn styling and enhancements * diff --git a/src/assets/css/kv-grid-expand.min.css b/src/assets/css/kv-grid-expand.min.css index aa0e7305..e329f9ed 100644 --- a/src/assets/css/kv-grid-expand.min.css +++ b/src/assets/css/kv-grid-expand.min.css @@ -2,7 +2,7 @@ * @package yii2-grid * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2018 - * @version 3.1.8 + * @version 3.2.0 * * Gridview ExpandRowColumn styling and enhancements * diff --git a/src/assets/css/kv-grid.css b/src/assets/css/kv-grid.css index 4b2c529a..832a4634 100644 --- a/src/assets/css/kv-grid.css +++ b/src/assets/css/kv-grid.css @@ -2,7 +2,7 @@ * @package yii2-grid * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2018 - * @version 3.1.8 + * @version 3.2.0 * * Yii2 Gridview widget styling and enhancements for Bootstrap. * diff --git a/src/assets/css/kv-grid.min.css b/src/assets/css/kv-grid.min.css index ea03317c..4ffe7f6b 100644 --- a/src/assets/css/kv-grid.min.css +++ b/src/assets/css/kv-grid.min.css @@ -2,7 +2,7 @@ * @package yii2-grid * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2018 - * @version 3.1.8 + * @version 3.2.0 * * Yii2 Gridview widget styling and enhancements for Bootstrap. * diff --git a/src/assets/js/kv-grid-checkbox.js b/src/assets/js/kv-grid-checkbox.js index 13ded495..26daafa6 100644 --- a/src/assets/js/kv-grid-checkbox.js +++ b/src/assets/js/kv-grid-checkbox.js @@ -1,8 +1,8 @@ /*! * @package yii2-grid * @author Kartik Visweswaran - * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2017 - * @version 3.1.8 + * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2018 + * @version 3.2.0 * * Client actions for kartik\grid\CheckboxColumn * diff --git a/src/assets/js/kv-grid-checkbox.min.js b/src/assets/js/kv-grid-checkbox.min.js index c279ae60..2664e4b7 100644 --- a/src/assets/js/kv-grid-checkbox.min.js +++ b/src/assets/js/kv-grid-checkbox.min.js @@ -1,8 +1,8 @@ /*! * @package yii2-grid * @author Kartik Visweswaran - * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2017 - * @version 3.1.8 + * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2018 + * @version 3.2.0 * * Client actions for yii2-grid CheckboxColumn * diff --git a/src/assets/js/kv-grid-editable.js b/src/assets/js/kv-grid-editable.js index ad90568e..2cac2b97 100644 --- a/src/assets/js/kv-grid-editable.js +++ b/src/assets/js/kv-grid-editable.js @@ -1,8 +1,8 @@ /*! * @package yii2-grid * @author Kartik Visweswaran - * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2017 - * @version 3.1.8 + * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2018 + * @version 3.2.0 * * Client actions for yii2-grid EditableColumn * diff --git a/src/assets/js/kv-grid-editable.min.js b/src/assets/js/kv-grid-editable.min.js index ec5b653f..1af68b11 100644 --- a/src/assets/js/kv-grid-editable.min.js +++ b/src/assets/js/kv-grid-editable.min.js @@ -1,8 +1,8 @@ /*! * @package yii2-grid * @author Kartik Visweswaran - * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2017 - * @version 3.1.8 + * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2018 + * @version 3.2.0 * * Client actions for yii2-grid EditableColumn * diff --git a/src/assets/js/kv-grid-expand.js b/src/assets/js/kv-grid-expand.js index e6b43d19..de062e45 100644 --- a/src/assets/js/kv-grid-expand.js +++ b/src/assets/js/kv-grid-expand.js @@ -1,8 +1,8 @@ /*! * @package yii2-grid * @author Kartik Visweswaran - * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2017 - * @version 3.1.8 + * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2018 + * @version 3.2.0 * * jQuery methods library for yii2-grid expand row column * diff --git a/src/assets/js/kv-grid-expand.min.js b/src/assets/js/kv-grid-expand.min.js index c21a12dc..b3a662b2 100644 --- a/src/assets/js/kv-grid-expand.min.js +++ b/src/assets/js/kv-grid-expand.min.js @@ -1,8 +1,8 @@ /*! * @package yii2-grid * @author Kartik Visweswaran - * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2017 - * @version 3.1.8 + * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2018 + * @version 3.2.0 * * jQuery methods library for yii2-grid expand row column * diff --git a/src/assets/js/kv-grid-export.js b/src/assets/js/kv-grid-export.js index d1194da0..643e3691 100644 --- a/src/assets/js/kv-grid-export.js +++ b/src/assets/js/kv-grid-export.js @@ -1,8 +1,8 @@ /*! * @package yii2-grid * @author Kartik Visweswaran - * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2017 - * @version 3.1.8 + * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2018 + * @version 3.2.0 * * Grid Export Validation Module for Yii's Gridview. Supports export of * grid data as CSV, HTML, or Excel. @@ -114,8 +114,6 @@ constructor: GridExport, getArray: function (expType) { var self = this, $table = self.clean(expType), head = [], data = {}; - /** @namespace self.config.colHeads */ - /** @namespace self.config.slugColHeads */ if (self.config.colHeads !== undefined && self.config.colHeads.length > 0) { head = self.config.colHeads; } else { @@ -229,7 +227,7 @@ safeRemove = function (selector) { $table.find(selector + '.' + self.gridId).remove(); }; - + if ($container.hasClass('kv-grid-wrapper')) { $tHead = $container.closest('.floatThead-wrapper').find('.kv-thead-float thead'); } else { @@ -261,6 +259,10 @@ } $table.find('.skip-export').remove(); $table.find('.skip-export-' + expType).remove(); + $table.find('.strip-tags-export').each(function () { + var $el = $(this), rawText = $el.text(); + $el.html(rawText); + }); var htmlContent = $table.html(); htmlContent = self.preProcess(htmlContent); $table.html(htmlContent); @@ -299,7 +301,6 @@ self.$form.submit(); }, exportHTML: function () { - /** @namespace self.config.cssFile */ var self = this, $table = self.clean('html'), cfg = self.config, css = (self.config.cssFile && cfg.cssFile.length) ? '' : '', html = templates.html.replace('{encoding}', self.encoding).replace('{css}', css).replace('{data}', @@ -308,8 +309,6 @@ }, exportPDF: function () { var self = this, $table = self.clean('pdf'); - /** @namespace self.config.contentAfter */ - /** @namespace self.config.contentBefore */ var before = isEmpty(self.config.contentBefore) ? '' : self.config.contentBefore, after = isEmpty(self.config.contentAfter) ? '' : self.config.contentAfter, css = self.config.css, @@ -327,25 +326,21 @@ var tmpColDelim = String.fromCharCode(11), // vertical tab character tmpRowDelim = String.fromCharCode(0); // null character // actual delimiter characters for CSV format - /** @namespace self.config.rowDelimiter */ - /** @namespace self.config.colDelimiter */ var colD = '"' + self.config.colDelimiter + '"', rowD = '"' + self.config.rowDelimiter + '"'; // grab text from table into CSV formatted string var txt = '"' + $rows.map(function (i, row) { - var $row = $(row), $cols = $row.find(self.columns); - return $cols.map(function (j, col) { - var $col = $(col), text = $col.text().trim(); - return text.replace(/"/g, '""'); // escape double quotes - }).get().join(tmpColDelim); - }).get().join(tmpRowDelim) - .split(tmpRowDelim).join(rowD) - .split(tmpColDelim).join(colD) + '"'; + var $row = $(row), $cols = $row.find(self.columns); + return $cols.map(function (j, col) { + var $col = $(col), text = $col.text().trim(); + return text.replace(/"/g, '""'); // escape double quotes + }).get().join(tmpColDelim); + }).get().join(tmpRowDelim) + .split(tmpRowDelim).join(rowD) + .split(tmpColDelim).join(colD) + '"'; self.download(expType, txt); }, exportJSON: function () { var self = this, out = self.getArray('json'); - /** @namespace self.config.indentSpace */ - /** @namespace self.config.jsonReplacer */ out = JSON.stringify(out, self.config.jsonReplacer, self.config.indentSpace); self.download('json', out); }, @@ -355,11 +350,10 @@ $table.find('td[data-raw-value]').each(function () { $td = $(this); if ($td.css('mso-number-format') || $td.css('mso-number-format') === 0 || $td.css( - 'mso-number-format') === '0') { + 'mso-number-format') === '0') { $td.html($td.attr('data-raw-value')).removeAttr('data-raw-value'); } }); - /** @namespace self.config.worksheet */ xls = templates.excel.replace('{encoding}', self.encoding).replace('{css}', css).replace('{worksheet}', self.config.worksheet).replace('{data}', $('
').html($table).html()).replace(/"/g, '\''); self.download('xls', xls); diff --git a/src/assets/js/kv-grid-export.min.js b/src/assets/js/kv-grid-export.min.js index 22afe891..48ef2a18 100644 --- a/src/assets/js/kv-grid-export.min.js +++ b/src/assets/js/kv-grid-export.min.js @@ -1,8 +1,8 @@ /*! * @package yii2-grid * @author Kartik Visweswaran - * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2017 - * @version 3.1.8 + * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2018 + * @version 3.2.0 * * Grid Export Validation Module for Yii's Gridview. Supports export of * grid data as CSV, HTML, or Excel. @@ -11,4 +11,5 @@ * Copyright: 2014 - 2018, Kartik Visweswaran, Krajee.com * For more JQuery plugins visit http://plugins.krajee.com * For more Yii related demos visit http://demos.krajee.com - */!function(e){"use strict";var t,o,n,r,i,a,l="urn:schemas-microsoft-com:office:";t=function(e,t,o){return e.split(t).join(o)},o=function(t,o){return null===t||void 0===t||0===t.length||o&&""===e.trim(t)},n=function(e,t,o,n){var r=screen.width/2-o/2,i=60,a=window.open("",t,"",!0);return a.close(),window.open(e,t,"toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width="+o+", height="+n+", top="+i+", left="+r)},r=function(e){return e.toLowerCase().replace(/[^\w ]+/g,"").replace(/ +/g,"-")},i={html:'{css}{data}',pdf:"{before}\n{data}\n{after}",excel:'{css}{data}',popup:'Grid Export - © Krajee{msg}'},a=function(t,o){var n=this,r=o.gridOpts,i=o.genOpts;n.$element=e(t),n.gridId=r.gridId,n.$grid=e("#"+r.gridId),n.dialogLib=o.dialogLib,n.messages=r.messages,n.target=r.target,n.exportConversions=r.exportConversions,n.showConfirmAlert=r.showConfirmAlert,n.filename=i.filename,n.expHash=i.expHash,n.showHeader=i.showHeader,n.showFooter=i.showFooter,n.showPageSummary=i.showPageSummary,n.$table=n.$grid.find(".kv-grid-table:first"),n.$form=n.$grid.find("form.kv-export-form"),n.encoding=n.$form.find('[name="export_encoding"]').val(),n.columns=n.showHeader?"td,th":"td",n.alertMsg=o.alertMsg,n.config=o.config,n.popup="",n.listen()},a.prototype={constructor:a,getArray:function(t){var n=this,i=n.clean(t),a=[],l={};return void 0!==n.config.colHeads&&n.config.colHeads.length>0?a=n.config.colHeads:i.find("thead tr th").each(function(t){var i=e(this).text().trim(),l=r(i);a[t]=!n.config.slugColHeads||o(l)?"col_"+t:l}),i.find('tbody tr:has("td")').each(function(t){l[t]={},e(this).children("td").each(function(o){var n=a[o];l[t][n]=e(this).text().trim()})}),l},setPopupAlert:function(e){var t=this;if(void 0!==t.popup.document)if(arguments.length&&arguments[1]){var o=t.popup.document.getElementsByTagName("body");setTimeout(function(){o[0].innerHTML=e},4e3)}else{var n=i.popup.replace("{msg}",e);t.popup.document.write(n)}},processExport:function(e,t){var n=this;setTimeout(function(){o(t)?n[e]():n[e](t)},100)},listenClick:function(e){var t=this,n=arguments.length>1?arguments[1]:"",r=window[t.dialogLib];t.$element.off("click.gridexport").on("click.gridexport",function(i){if(i.stopPropagation(),i.preventDefault(),!t.showConfirmAlert)return void t.processExport(e,n);var a=t.messages,l=o(t.alertMsg)?"":t.alertMsg,s=o(a.allowPopups)?"":a.allowPopups,c=o(a.confirmDownload)?"":a.confirmDownload,d="";return d=l.length&&s.length?l+"\n\n"+s:!l.length&&s.length?s:l.length&&!s.length?l:"",c.length&&(d=d+"\n\n"+c),o(d)?void 0:(r.confirm(d,function(o){o&&t.processExport(e,n),i.preventDefault()}),!1)})},listen:function(){var e=this;"_popup"===e.target&&e.$form.on("submit.gridexport",function(){setTimeout(function(){e.setPopupAlert(e.messages.downloadComplete,!0)},1e3)}),e.$element.hasClass("export-csv")&&e.listenClick("exportTEXT","csv"),e.$element.hasClass("export-txt")&&e.listenClick("exportTEXT","txt"),e.$element.hasClass("export-html")&&e.listenClick("exportHTML"),e.$element.hasClass("export-xls")&&e.listenClick("exportEXCEL"),e.$element.hasClass("export-json")&&e.listenClick("exportJSON"),e.$element.hasClass("export-pdf")&&e.listenClick("exportPDF")},clean:function(t){var o,n=this,r=n.$table.clone(),i=n.$table.closest(".kv-grid-container"),a=function(e){r.find(e+"."+n.gridId).remove()};o=i.hasClass("kv-grid-wrapper")?i.closest(".floatThead-wrapper").find(".kv-thead-float thead"):i.find(".kv-thead-float thead"),o.length&&(o=o.clone(),r.find("thead").before(o).remove()),r.find("tr.filters").remove(),r.find("th").removeAttr("rowspan"),r.find("th").find("a").each(function(){e(this).contents().unwrap()}),r.find("input").remove(),n.showHeader||r.children("thead").remove(),n.showPageSummary||a(".kv-page-summary-container"),n.showFooter||a(".kv-footer-container"),n.showCaption||a(".kv-caption-container"),r.find(".skip-export").remove(),r.find(".skip-export-"+t).remove();var l=r.html();return l=n.preProcess(l),r.html(l),r},preProcess:function(e){var o,n=this,r=n.exportConversions,i=r.length,a=e;if(i>0)for(var l=0;i>l;l++)o=r[l],a=t(a,o.from,o.to);return a},download:function(e,t){var r=this,i=r.$element,a=i.attr("data-mime")||"text/plain",l=i.attr("data-hash")||"",s=o(r.config)?{}:r.config,c=function(e,t){r.$form.find('[name="export_'+e+'"]').val(t)};"json"===e&&s.jsonReplacer&&delete s.jsonReplacer,c("filetype",e),c("filename",r.filename),c("content",t),c("mime",a),c("hash",l),c("config",JSON.stringify(s)),"_popup"===r.target&&(r.popup=n("","kvDownloadDialog",350,120),r.popup.focus(),r.setPopupAlert(r.messages.downloadProgress)),r.$form.submit()},exportHTML:function(){var t=this,o=t.clean("html"),n=t.config,r=t.config.cssFile&&n.cssFile.length?'':"",a=i.html.replace("{encoding}",t.encoding).replace("{css}",r).replace("{data}",e("
").html(o).html());t.download("html",a)},exportPDF:function(){var t=this,n=t.clean("pdf"),r=o(t.config.contentBefore)?"":t.config.contentBefore,a=o(t.config.contentAfter)?"":t.config.contentAfter,l=t.config.css,s=i.pdf.replace("{css}",l).replace("{before}",r).replace("{after}",a).replace("{data}",e("
").html(n).html());t.download("pdf",s)},exportTEXT:function(t){var o=this,n=o.clean(t),r=n.find("tr:has("+o.columns+")"),i=String.fromCharCode(11),a=String.fromCharCode(0),l='"'+o.config.colDelimiter+'"',s='"'+o.config.rowDelimiter+'"',c='"'+r.map(function(t,n){var r=e(n),a=r.find(o.columns);return a.map(function(t,o){var n=e(o),r=n.text().trim();return r.replace(/"/g,'""')}).get().join(i)}).get().join(a).split(a).join(s).split(i).join(l)+'"';o.download(t,c)},exportJSON:function(){var e=this,t=e.getArray("json");t=JSON.stringify(t,e.config.jsonReplacer,e.config.indentSpace),e.download("json",t)},exportEXCEL:function(){var t,o,n=this,r=n.clean("xls"),a=n.config,l=a.cssFile&&n.config.cssFile.length?'':"";r.find("td[data-raw-value]").each(function(){o=e(this),(o.css("mso-number-format")||0===o.css("mso-number-format")||"0"===o.css("mso-number-format"))&&o.html(o.attr("data-raw-value")).removeAttr("data-raw-value")}),t=i.excel.replace("{encoding}",n.encoding).replace("{css}",l).replace("{worksheet}",n.config.worksheet).replace("{data}",e("
").html(r).html()).replace(/"/g,"'"),n.download("xls",t)}},e.fn.gridexport=function(t){var o=Array.apply(null,arguments);return o.shift(),this.each(function(){var n=e(this),r=n.data("gridexport"),i="object"==typeof t&&t;r||n.data("gridexport",r=new a(this,e.extend({},e.fn.gridexport.defaults,i,e(this).data()))),"string"==typeof t&&r[t].apply(r,o)})},e.fn.gridexport.defaults={dialogLib:"krajeeDialog"},e.fn.gridexport.Constructor=a}(window.jQuery); \ No newline at end of file + */ +!function(t){"use strict";var e,o,i,n,r,s,a="urn:schemas-microsoft-com:office:";e=function(t,e,o){return t.split(e).join(o)},o=function(e,o){return null==e||0===e.length||o&&""===t.trim(e)},i=function(t,e,o,i){var n=screen.width/2-o/2;return window.open("",e,"",!0).close(),window.open(t,e,"toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width="+o+", height="+i+", top=60, left="+n)},n=function(t){return t.toLowerCase().replace(/[^\w ]+/g,"").replace(/ +/g,"-")},r={html:'{css}{data}',pdf:"{before}\n{data}\n{after}",excel:'{css}\x3c!--[if gte mso 9]>{worksheet}{data}',popup:'Grid Export - © Krajee{msg}'},(s=function(e,o){var i=o.gridOpts,n=o.genOpts;this.$element=t(e),this.gridId=i.gridId,this.$grid=t("#"+i.gridId),this.dialogLib=o.dialogLib,this.messages=i.messages,this.target=i.target,this.exportConversions=i.exportConversions,this.showConfirmAlert=i.showConfirmAlert,this.filename=n.filename,this.expHash=n.expHash,this.showHeader=n.showHeader,this.showFooter=n.showFooter,this.showPageSummary=n.showPageSummary,this.$table=this.$grid.find(".kv-grid-table:first"),this.$form=this.$grid.find("form.kv-export-form"),this.encoding=this.$form.find('[name="export_encoding"]').val(),this.columns=this.showHeader?"td,th":"td",this.alertMsg=o.alertMsg,this.config=o.config,this.popup="",this.listen()}).prototype={constructor:s,getArray:function(e){var i=this,r=i.clean(e),s=[],a={};return void 0!==i.config.colHeads&&i.config.colHeads.length>0?s=i.config.colHeads:r.find("thead tr th").each(function(e){var r=t(this).text().trim(),a=n(r);s[e]=!i.config.slugColHeads||o(a)?"col_"+e:a}),r.find('tbody tr:has("td")').each(function(e){a[e]={},t(this).children("td").each(function(o){var i=s[o];a[e][i]=t(this).text().trim()})}),a},setPopupAlert:function(t){if(void 0!==this.popup.document)if(arguments.length&&arguments[1]){var e=this.popup.document.getElementsByTagName("body");setTimeout(function(){e[0].innerHTML=t},4e3)}else{var o=r.popup.replace("{msg}",t);this.popup.document.write(o)}},processExport:function(t,e){var i=this;setTimeout(function(){o(e)?i[t]():i[t](e)},100)},listenClick:function(t){var e=this,i=arguments.length>1?arguments[1]:"",n=window[e.dialogLib];e.$element.off("click.gridexport").on("click.gridexport",function(r){if(r.stopPropagation(),r.preventDefault(),e.showConfirmAlert){var s=e.messages,a=o(e.alertMsg)?"":e.alertMsg,l=o(s.allowPopups)?"":s.allowPopups,c=o(s.confirmDownload)?"":s.confirmDownload,h="";if(h=a.length&&l.length?a+"\n\n"+l:!a.length&&l.length?l:a.length&&!l.length?a:"",c.length&&(h=h+"\n\n"+c),!o(h))return n.confirm(h,function(o){o&&e.processExport(t,i),r.preventDefault()}),!1}else e.processExport(t,i)})},listen:function(){var t=this;"_popup"===t.target&&t.$form.on("submit.gridexport",function(){setTimeout(function(){t.setPopupAlert(t.messages.downloadComplete,!0)},1e3)}),t.$element.hasClass("export-csv")&&t.listenClick("exportTEXT","csv"),t.$element.hasClass("export-txt")&&t.listenClick("exportTEXT","txt"),t.$element.hasClass("export-html")&&t.listenClick("exportHTML"),t.$element.hasClass("export-xls")&&t.listenClick("exportEXCEL"),t.$element.hasClass("export-json")&&t.listenClick("exportJSON"),t.$element.hasClass("export-pdf")&&t.listenClick("exportPDF")},clean:function(e){var o,i=this,n=i.$table.clone(),r=i.$table.closest(".kv-grid-container"),s=function(t){n.find(t+"."+i.gridId).remove()};(o=r.hasClass("kv-grid-wrapper")?r.closest(".floatThead-wrapper").find(".kv-thead-float thead"):r.find(".kv-thead-float thead")).length&&(o=o.clone(),n.find("thead").before(o).remove()),n.find("tr.filters").remove(),n.find("th").removeAttr("rowspan"),n.find("th").find("a").each(function(){t(this).contents().unwrap()}),n.find("input").remove(),i.showHeader||n.children("thead").remove(),i.showPageSummary||s(".kv-page-summary-container"),i.showFooter||s(".kv-footer-container"),i.showCaption||s(".kv-caption-container"),n.find(".skip-export").remove(),n.find(".skip-export-"+e).remove(),n.find(".strip-tags-export").each(function(){var e=t(this),o=e.text();e.html(o)});var a=n.html();return a=i.preProcess(a),n.html(a),n},preProcess:function(t){var o,i=this.exportConversions,n=i.length,r=t;if(n>0)for(var s=0;s':"",n=r.html.replace("{encoding}",this.encoding).replace("{css}",i).replace("{data}",t("
").html(e).html());this.download("html",n)},exportPDF:function(){var e=this.clean("pdf"),i=o(this.config.contentBefore)?"":this.config.contentBefore,n=o(this.config.contentAfter)?"":this.config.contentAfter,s=this.config.css,a=r.pdf.replace("{css}",s).replace("{before}",i).replace("{after}",n).replace("{data}",t("
").html(e).html());this.download("pdf",a)},exportTEXT:function(e){var o=this,i=o.clean(e).find("tr:has("+o.columns+")"),n=String.fromCharCode(11),r=String.fromCharCode(0),s='"'+o.config.colDelimiter+'"',a='"'+o.config.rowDelimiter+'"',l='"'+i.map(function(e,i){return t(i).find(o.columns).map(function(e,o){return t(o).text().trim().replace(/"/g,'""')}).get().join(n)}).get().join(r).split(r).join(a).split(n).join(s)+'"';o.download(e,l)},exportJSON:function(){var t=this.getArray("json");t=JSON.stringify(t,this.config.jsonReplacer,this.config.indentSpace),this.download("json",t)},exportEXCEL:function(){var e,o,i=this.clean("xls"),n=this.config.cssFile&&this.config.cssFile.length?'':"";i.find("td[data-raw-value]").each(function(){((o=t(this)).css("mso-number-format")||0===o.css("mso-number-format")||"0"===o.css("mso-number-format"))&&o.html(o.attr("data-raw-value")).removeAttr("data-raw-value")}),e=r.excel.replace("{encoding}",this.encoding).replace("{css}",n).replace("{worksheet}",this.config.worksheet).replace("{data}",t("
").html(i).html()).replace(/"/g,"'"),this.download("xls",e)}},t.fn.gridexport=function(e){var o=Array.apply(null,arguments);return o.shift(),this.each(function(){var i=t(this),n=i.data("gridexport"),r="object"==typeof e&&e;n||i.data("gridexport",n=new s(this,t.extend({},t.fn.gridexport.defaults,r,t(this).data()))),"string"==typeof e&&n[e].apply(n,o)})},t.fn.gridexport.defaults={dialogLib:"krajeeDialog"},t.fn.gridexport.Constructor=s}(window.jQuery); \ No newline at end of file diff --git a/src/assets/js/kv-grid-group.js b/src/assets/js/kv-grid-group.js index 0dc7e0e2..32be60f7 100644 --- a/src/assets/js/kv-grid-group.js +++ b/src/assets/js/kv-grid-group.js @@ -1,8 +1,8 @@ /*! * @package yii2-grid * @author Kartik Visweswaran - * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2017 - * @version 3.1.8 + * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2018 + * @version 3.2.0 * * Grid grouping jquery library created for yii2-grid. * diff --git a/src/assets/js/kv-grid-group.min.js b/src/assets/js/kv-grid-group.min.js index c56bc110..30ce2972 100644 --- a/src/assets/js/kv-grid-group.min.js +++ b/src/assets/js/kv-grid-group.min.js @@ -1,8 +1,8 @@ /*! * @package yii2-grid * @author Kartik Visweswaran - * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2017 - * @version 3.1.8 + * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2018 + * @version 3.2.0 * * Grid grouping jquery library created for yii2-grid. * diff --git a/src/assets/js/kv-grid-radio.js b/src/assets/js/kv-grid-radio.js index 3f0e724f..7cd58e89 100644 --- a/src/assets/js/kv-grid-radio.js +++ b/src/assets/js/kv-grid-radio.js @@ -1,8 +1,8 @@ /*! * @package yii2-grid * @author Kartik Visweswaran - * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2017 - * @version 3.1.8 + * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2018 + * @version 3.2.0 * * Client actions for yii2-grid RadioColumn * diff --git a/src/assets/js/kv-grid-radio.min.js b/src/assets/js/kv-grid-radio.min.js index 9908ae22..4d8fcdbf 100644 --- a/src/assets/js/kv-grid-radio.min.js +++ b/src/assets/js/kv-grid-radio.min.js @@ -1,8 +1,8 @@ /*! * @package yii2-grid * @author Kartik Visweswaran - * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2017 - * @version 3.1.8 + * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2018 + * @version 3.2.0 * * Client actions for yii2-grid RadioColumn * diff --git a/src/assets/js/kv-grid-toggle.js b/src/assets/js/kv-grid-toggle.js index 69c6bc0f..f9afed72 100644 --- a/src/assets/js/kv-grid-toggle.js +++ b/src/assets/js/kv-grid-toggle.js @@ -1,8 +1,8 @@ /*! * @package yii2-grid * @author Kartik Visweswaran - * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2017 - * @version 3.1.8 + * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2018 + * @version 3.2.0 * * jQuery methods library for yii2-grid toggle data * diff --git a/src/assets/js/kv-grid-toggle.min.js b/src/assets/js/kv-grid-toggle.min.js index 11aab6f7..a283f895 100644 --- a/src/assets/js/kv-grid-toggle.min.js +++ b/src/assets/js/kv-grid-toggle.min.js @@ -1,8 +1,8 @@ /*! * @package yii2-grid * @author Kartik Visweswaran - * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2017 - * @version 3.1.8 + * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2018 + * @version 3.2.0 * * jQuery methods library for yii2-grid toggle data *