diff --git a/CHANGE.md b/CHANGE.md
index 3c011291..6252d052 100755
--- a/CHANGE.md
+++ b/CHANGE.md
@@ -3,11 +3,15 @@ Change Log: `yii2-grid`
## Version 3.3.3
-**Date:** _under development_
+**Date:** 23-Aug-2019
+- (enh #922): Correct documentation for `floatHeaderOptions['top']`.
+- (enh #918): Allow specific elements to be skipped from export via `export['skipExportElements']`.
- Update GridView Asset Bundle Dependencies.
+- (enh #919, #909): Enhance expand row cell click.
- (enh #917): Correct checkbox column highlight behavior to accomodate changes in yiisoft/yii2#17332.
-- (enh #916): Set ActionColumn button label aria-hidden as true for screen reader.
+- (enh #916): Set ActionColumn button label `aria-hidden` as true for screen reader.
+- (enh #773): Enhance grid grouping for more correct summary calculations for nested `GridView`.
## Version 3.3.2
diff --git a/README.md b/README.md
index c733d4ce..242aeb12 100755
--- a/README.md
+++ b/README.md
@@ -136,7 +136,7 @@ echo GridView::widget([
'responsive' => true,
'hover' => true,
'floatHeader' => true,
- 'floatHeaderOptions' => ['scrollingTop' => $scrollingTop],
+ 'floatHeaderOptions' => ['top' => $scrollingTop],
'showPageSummary' => true,
'panel' => [
'type' => GridView::TYPE_PRIMARY
diff --git a/src/ColumnTrait.php b/src/ColumnTrait.php
index e95ec0c4..5dbaf831 100644
--- a/src/ColumnTrait.php
+++ b/src/ColumnTrait.php
@@ -539,6 +539,7 @@ protected function fetchContentOptions($model, $key, $index)
Html::addCssStyle($options, "width:{$this->width};");
}
$options['data-col-seq'] = array_search($this, $this->grid->columns);
+ Html::addCssClass($options, $this->grid->options['id']);
return $options;
}
@@ -609,9 +610,9 @@ protected function initGrouping()
if (empty($this->group)) {
return;
}
+ Html::addCssClass($this->headerOptions, ['kv-grid-group-header', $this->grid->options['id']]);
+ Html::addCssClass($this->filterOptions, ['kv-grid-group-filter', $this->grid->options['id']]);
$view = $this->grid->getView();
- Html::addCssClass($this->headerOptions, 'kv-grid-group-header');
- Html::addCssClass($this->filterOptions, 'kv-grid-group-filter');
$this->headerOptions['data-group-key'] = $this->filterOptions['data-group-key'] = $this->columnKey;
GridGroupAsset::register($view);
$id = $this->grid->options['id'];
@@ -632,7 +633,7 @@ protected function parseGrouping(&$options, $model, $key, $index)
if (empty($this->group)) {
return;
}
- Html::addCssClass($options, 'kv-grid-group');
+ Html::addCssClass($options, ['kv-grid-group', $this->grid->options['id']]);
$options['data-group-key'] = $this->columnKey;
if (!empty($this->groupOddCssClass)) {
$options['data-odd-css'] = $this->parseVal($this->groupOddCssClass, $model, $key, $index);
diff --git a/src/GridView.php b/src/GridView.php
index f8e90092..c9dfe745 100644
--- a/src/GridView.php
+++ b/src/GridView.php
@@ -9,6 +9,7 @@
namespace kartik\grid;
+use Closure;
use kartik\base\BootstrapInterface;
use kartik\base\BootstrapTrait;
use kartik\base\Config;
@@ -923,6 +924,8 @@ class GridView extends YiiGridView implements BootstrapInterface
* - `menuOptions`: _array_, HTML attributes for the export dropdown menu. Defaults to `['class' => 'dropdown-menu
* dropdown-menu-right']`. This property is to be setup exactly as the `options` property required by the
* [[\yii\bootstrap\Dropdown]] widget.
+ * - `skipExportElements`: _array_, the list of jQuery element selectors that will be skipped and removed from
+ * export. Defaults to `['.sr-only', '.hide']`.
*/
public $export = [];
@@ -1219,6 +1222,7 @@ public function renderPageSummary()
if (!isset($this->pageSummaryRowOptions['class'])) {
$this->pageSummaryRowOptions['class'] = ($this->isBs4() ? 'table-' : '') . 'warning kv-page-summary';
}
+ Html::addCssClass($this->pageSummaryRowOptions, $this->options['id']);
$row = $this->getPageSummaryRow();
if ($row === null) {
return '';
@@ -1284,6 +1288,31 @@ public function renderTableBody()
return $content;
}
+ /**
+ * Renders a table row with the given data model and key.
+ * @param mixed $model the data model to be rendered
+ * @param mixed $key the key associated with the data model
+ * @param int $index the zero-based index of the data model among the model array returned by [[dataProvider]].
+ * @return string the rendering result
+ */
+ public function renderTableRow($model, $key, $index)
+ {
+ $cells = [];
+ /* @var $column Column */
+ foreach ($this->columns as $column) {
+ $cells[] = $column->renderDataCell($model, $key, $index);
+ }
+ if ($this->rowOptions instanceof Closure) {
+ $options = call_user_func($this->rowOptions, $model, $key, $index, $this);
+ } else {
+ $options = $this->rowOptions;
+ }
+ $options['data-key'] = is_array($key) ? json_encode($key) : (string) $key;
+ Html::addCssClass($options, $this->options['id']);
+ $this->rowOptions = $options;
+ return Html::tag('tr', implode('', $cells), $options);
+ }
+
/**
* Renders the toggle data button.
*
@@ -1575,6 +1604,7 @@ protected function initExport()
],
'options' => ['class' => 'btn ' . $this->_defaultBtnCss, 'title' => Yii::t('kvgrid', 'Export')],
'menuOptions' => ['class' => 'dropdown-menu dropdown-menu-right '],
+ 'skipExportElements' => ['.sr-only', '.hide'],
],
$this->export
);
@@ -2196,6 +2226,7 @@ protected function registerAssets()
'target' => ArrayHelper::getValue($this->export, 'target', self::TARGET_BLANK),
'messages' => $this->export['messages'],
'exportConversions' => $this->exportConversions,
+ 'skipExportElements' => $this->export['skipExportElements'],
'showConfirmAlert' => ArrayHelper::getValue($this->export, 'showConfirmAlert', true),
]
);
diff --git a/src/assets/js/kv-grid-expand.js b/src/assets/js/kv-grid-expand.js
index 5aef5467..a2640ebd 100644
--- a/src/assets/js/kv-grid-expand.js
+++ b/src/assets/js/kv-grid-expand.js
@@ -303,8 +303,9 @@ var kvExpandRow;
expandRow(false);
}
}
- handler($cell, 'click', function () {
+ handler($cell, 'click', function (event) {
toggleRow($cell);
+ event.stopPropagation();
});
handler($row, 'click', function (event) {
var target = event.target, clickDisabled = $(target).length &&
diff --git a/src/assets/js/kv-grid-expand.min.js b/src/assets/js/kv-grid-expand.min.js
index 34d3785b..b7911c9a 100644
--- a/src/assets/js/kv-grid-expand.min.js
+++ b/src/assets/js/kv-grid-expand.min.js
@@ -10,5 +10,4 @@
* Copyright: 2014 - 2019, Kartik Visweswaran, Krajee.com
* For more JQuery plugins visit http://plugins.krajee.com
* For more Yii related demos visit http://demos.krajee.com
- */
-var kvExpandRow;!function(e){"use strict";kvExpandRow=function(t,a){var n=".kvExpandRowColumn",l="kvRowNum_"+a,o=t.gridId,d=t.hiddenFromExport,i=t.detailUrl,r=t.onDetailLoaded,s=t.expandIcon,c=t.collapseIcon,v=t.expandTitle,p=t.collapseTitle,f=t.expandAllTitle,u=t.collapseAllTitle,x=t.expandOneOnly,h=t.enableRowClick,k=t.rowClickExcludedTags,g=t.enableCache,w=t.extraData,C=d?t.rowCssClass+" skip-export":t.rowCssClass,m=t.animationDuration,A=e("#"+o),y="."+a,b=A.find(".kv-expand-header-cell.kv-batch-toggle"+y),R=b.find(".kv-expand-header-icon"),E=void 0===t.collapseAll?!1:t.collapseAll,T=void 0===t.expandAll?!1:t.expandAll,I=A.find("td.kv-expand-icon-cell"+y+" .kv-expand-row:not(.kv-state-disabled)"),N=I.length,D="kv-expand-detail-loading",j=function(){var t=A.find("td.kv-expand-icon-cell"+y+":first"),a=t&&t.length?t.closest("tr"):"",n=0;return a&&a.length?(a.find("> td").each(function(){"none"!==e(this).css("display")&&n++}),n):0},O=j(),L=function(e){return e.hasClass("kv-state-collapsed")&&!e.hasClass("kv-state-disabled")},P=function(e){return e.hasClass("kv-state-expanded")&&!e.hasClass("kv-state-disabled")},S=function(e,t){e.length&&e.removeClass(t).addClass(t)},U=function(e){e.removeClass("kv-state-collapsed").addClass("kv-state-expanded")},F=function(e){e.removeClass("kv-state-expanded").addClass("kv-state-collapsed")},K=function(e){S(e,D)},Q=function(e){if(e.length){var t=isNaN(m)?1e3:m+200;setTimeout(function(){e.removeClass(D)},t)}},_=function(){var e=A.data(l);return e=e?parseInt(e):0,isNaN(e)?0:e},q=function(e){A.data(l,e)},z=function(){var e=_();A.data(l,e+1)},B=function(e,t,a,l){var o=l?t:t.split(" ").join(n+" ")+n;e.length&&e.off(o).on(o,a)};return A.data(l)||q(0),0===w.length&&(w={}),0===I.length?void S(b,"kv-state-disabled"):(I.each(function(){var a,n,l=e(this),o=l.find(">.kv-expand-icon"),d=o.closest(".kv-expand-icon-cell"),f=l.closest("tr"),u=d.find(".kv-expand-detail"),j=l.find(".kv-expanded-row"+y+":first"),S=j.data("key"),q=j.data("index");if(!L(o)&&!P(o))return!0;0===j.length&&(S=f.data("key"),a=f.next('tr.kv-expand-detail-row[data-key="'+S+'"]'),j=a.find(".kv-expanded-row"));var G=function(t){var a=e.extend({expandRowKey:S,expandRowInd:q},w),n=g?0===j.html().length:!0;return i.length>0&&n?void e.ajax({type:"POST",data:a,url:i,beforeSend:function(){K(d),A.trigger("kvexprow:beforeLoad",[q,S,w])},success:function(e){j.html(e),Q(d),"function"==typeof r&&r(),t(),A.trigger("kvexprow:loaded",[q,S,w])},error:function(){j.html('
Error fetching data. Please try again later.
'),A.trigger("kvexprow:error",[q,S,w]),Q(d)}}):(Q(d),void t())},H=function(t){A.find('tr[data-index="'+q+'"]').remove(),j.hide(),f.after(j);var a='';j.wrap('').parent().wrap(a),o.html(c),i.attr("title",v),t?j.slideDown(m,function(){F(o),j.show()}):(j.show(),F(o));var n=f.prevAll(),l=f.index()+1;n.push(f),e.each(n,function(t,a){var n=e(a).find("td[rowspan]");e.each(n,function(t,n){var o=parseInt(e(n).attr("rowspan"));e(a).index()+o>l&&e(n).attr("rowspan",o+1)})}),0===d.length&&Q(i)},J=function(){K(i),u.html(""),o.html(s),i.attr("title",p),n=j.closest(".kv-expand-detail-row"),j.slideUp(m,function(){j.unwrap().unwrap(),j.appendTo(u),U(o);var t=f.prevAll();t.push(f);var a=f.index()+1;e.each(t,function(t,n){var l=e(n).find("td[rowspan]");e.each(l,function(t,l){var o=parseInt(e(l).attr("rowspan"));e(n).index()+o>a&&e(l).attr("rowspan",o-1)})})}),Q(i)},M=function(){var a,n,l=!1,d=!1;if(!i.hasClass(D)){if(L(o)){if(n=x&&!E){if(a=e.extend({},t,{collapseAll:!0}),I.each(function(){return e(this).closest(".kv-expand-icon-cell").hasClass(D)?void(d=!0):void 0}),d)return;kvExpandRow(a),l=!0}return G(function(){H(!0)}),void(n&&!l||(A.trigger("kvexprow:toggle",[q,S,w,!0]),o.focus()))}P(o)&&(J(),A.trigger("kvexprow:toggle",[q,S,w,!1]),o.focus())}};return T?(L(o)&&G(function(){H(!0),z(),_()>=N&&(Q(b),R.focus())}),_()>=N&&(Q(b),R.focus()),!0):E?(P(o)&&(J(),z(),_()>=N&&(Q(b),R.focus())),_()>=N&&(Q(b),R.focus()),!0):(P(o)&&(d?G(function(){H(!1)}):H(!1)),B(i,"click",function(e){M(i),e.stopPropagation()}),void B(f,"click",function(t){var a=t.target,n=e(a).length&&e(a).hasClass("kv-disable-click")||-1!==e.inArray(a.nodeName,k);h&&!n&&M(i)}))}),void(b.length&&B(b,"click",function(){if(!b.hasClass(D)&&0!==I.length){var n=L(R),l=P(R),o=e.extend({},t,{expandAll:l,collapseAll:n});K(b),l?(q(I.find(".kv-state-collapsed").length),U(R),R.html(c),b.attr("title",u),A.trigger("kvexprow:toggleAll",[w,!1])):n&&(q(I.find(".kv-state-expanded").length),F(R),R.html(s),b.attr("title",f),A.trigger("kvexprow:toggleAll",[w,!0])),kvExpandRow(o,a)}})))}}(window.jQuery);
\ No newline at end of file
diff --git a/src/assets/js/kv-grid-export.js b/src/assets/js/kv-grid-export.js
index c02bd7ef..33dcf098 100644
--- a/src/assets/js/kv-grid-export.js
+++ b/src/assets/js/kv-grid-export.js
@@ -86,6 +86,7 @@
self.messages = gridOpts.messages;
self.target = gridOpts.target;
self.exportConversions = gridOpts.exportConversions;
+ self.skipExportElements = gridOpts.skipExportElements;
self.showConfirmAlert = gridOpts.showConfirmAlert;
self.action = gridOpts.action;
self.bom = gridOpts.bom;
@@ -210,10 +211,15 @@
},
clean: function (expType) {
var self = this, $table = self.$table.clone(), $tHead, cssStyles = self.$element.data('cssStyles') || {},
- $container = self.$table.closest('.kv-grid-container'),
+ $container = self.$table.closest('.kv-grid-container'), skipElements = self.skipExportElements,
safeRemove = function (selector) {
$table.find(selector + '.' + self.gridId).remove();
};
+ if (skipElements.length) {
+ $.each(skipElements, function(key, selector) {
+ $table.find(selector).remove();
+ });
+ }
if (expType === 'html') {
$table.find('.kv-grid-boolean').remove();
}
diff --git a/src/assets/js/kv-grid-export.min.js b/src/assets/js/kv-grid-export.min.js
index fd89c115..3ac41030 100644
--- a/src/assets/js/kv-grid-export.min.js
+++ b/src/assets/js/kv-grid-export.min.js
@@ -11,4 +11,4 @@
* Copyright: 2014 - 2019, Kartik Visweswaran, Krajee.com
* For more JQuery plugins visit http://plugins.krajee.com
* For more Yii related demos visit http://demos.krajee.com
- */!function(f){"use strict";var m,r,e="urn:schemas-microsoft-com:office:";m={replaceAll:function(e,t,o){return e.split(t).join(o)},isEmpty:function(e,t){return null==e||0===e.length||t&&""===f.trim(e)},popupDialog:function(e,t,o,n){var i=screen.width/2-o/2;return window.open("",t,"",!0).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=60, left="+i)},slug:function(e){return e.toLowerCase().replace(/[^\w ]+/g,"").replace(/ +/g,"-")},templates:{html:'{css}{data}',pdf:"{before}\n{data}\n{after}",excel:'{css}\x3c!--[if gte mso 9]>{worksheet}{data}',popup:'Grid Export - © Krajee{msg}'}},(r=function(e,t){var o=this,n=t.gridOpts,i=t.genOpts;o.$element=f(e),o.gridId=n.gridId,o.$grid=f("#"+o.gridId),o.dialogLib=t.dialogLib,o.messages=n.messages,o.target=n.target,o.exportConversions=n.exportConversions,o.showConfirmAlert=n.showConfirmAlert,o.action=n.action,o.bom=n.bom,o.encoding=n.encoding,o.module=n.module,o.filename=i.filename,o.expHash=i.expHash,o.showHeader=i.showHeader,o.showFooter=i.showFooter,o.showPageSummary=i.showPageSummary,o.$table=o.$grid.find(".kv-grid-table:first"),o.columns=o.showHeader?"td,th":"td",o.alertMsg=t.alertMsg,o.config=t.config,o.popup="",o.listen()}).prototype={constructor:r,getArray:function(e){var n=this,t=n.clean(e),i=[],r={};return void 0!==n.config.colHeads&&0",{name:e}).val(t).hide()};"json"===e&&p.jsonReplacer&&delete p.jsonReplacer,o=s?h(s.getCsrfParam()||"_csrf",s.getCsrfToken()||null):null,(n="_popup"===d)&&(d="kvDownloadDialog",i.popup=m.popupDialog("",d,350,120),i.popup.focus(),i.setPopupAlert(i.messages.downloadProgress)),f("",{action:i.action,target:d,method:"post",css:{display:"none"}}).append(h("export_filetype",e),h("export_filename",i.filename)).append(h("export_encoding",i.encoding),h("export_bom",i.bom?1:0)).append(h("export_content",t),h("module_id",i.module),o).append(h("export_mime",a),h("export_hash",l),h("hash_export_config",c)).append(h("export_config",JSON.stringify(p))).appendTo("body").submit().remove(),n&&i.setPopupAlert(i.messages.downloadComplete,!0)},exportHTML:function(){var e,t=this.clean("html"),o=this.config,n=o.cssFile?o.cssFile:[],i="";e=m.templates.html.replace("{encoding}",this.encoding),f.each(n,function(e,t){i+='\n'}),e=e.replace("{css}",i).replace("{data}",f("").html(t).html()),this.download("html",e)},exportPDF:function(){var e=this,t=e.clean("pdf"),o=m.isEmpty(e.config.contentBefore)?"":e.config.contentBefore,n=m.isEmpty(e.config.contentAfter)?"":e.config.contentAfter,i=e.config.css,r=m.templates.pdf.replace("{css}",i).replace("{before}",o).replace("{after}",n).replace("{data}",f("").html(t).html());e.download("pdf",r)},exportTEXT:function(e){var o=this,t=o.clean(e).find("tr:has("+o.columns+")"),n=String.fromCharCode(11),i=String.fromCharCode(0),r='"'+o.config.colDelimiter+'"',a='"'+o.config.rowDelimiter+'"',s='"'+t.map(function(e,t){return f(t).find(o.columns).map(function(e,t){return f(t).text().trim().replace(/"/g,'""')}).get().join(n)}).get().join(i).split(i).join(a).split(n).join(r)+'"';o.download(e,s)},exportJSON:function(){var e=this.getArray("json");e=JSON.stringify(e,this.config.jsonReplacer,this.config.indentSpace),this.download("json",e)},exportEXCEL:function(){var e,t,o=this,n=o.clean("xls"),i=o.config.cssFile&&o.config.cssFile.length?'':"";n.find("td[data-raw-value]").each(function(){((t=f(this)).css("mso-number-format")||0===t.css("mso-number-format")||"0"===t.css("mso-number-format"))&&t.html(t.attr("data-raw-value")).removeAttr("data-raw-value")}),e=m.templates.excel.replace("{encoding}",o.encoding).replace("{css}",i).replace("{worksheet}",o.config.worksheet).replace("{data}",f("").html(n).html()).replace(/"/g,"'"),o.download("xls",e)}},f.fn.gridexport=function(n){var i=Array.apply(null,arguments);return i.shift(),this.each(function(){var e=f(this),t=e.data("gridexport"),o="object"==typeof n&&n;t||e.data("gridexport",t=new r(this,f.extend({},f.fn.gridexport.defaults,o,f(this).data()))),"string"==typeof n&&t[n].apply(t,i)})},f.fn.gridexport.defaults={dialogLib:"krajeeDialog"},f.fn.gridexport.Constructor=r}(window.jQuery);
\ No newline at end of file
+ */!function(e){"use strict";var t,o,n="urn:schemas-microsoft-com:office:",r="http://www.w3.org/TR/REC-html40";t={replaceAll:function(e,t,o){return e.split(t).join(o)},isEmpty:function(t,o){return null===t||void 0===t||0===t.length||o&&""===e.trim(t)},popupDialog: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)},slug:function(e){return e.toLowerCase().replace(/[^\w ]+/g,"").replace(/ +/g,"-")},templates:{html:'{css}{data}',pdf:"{before}\n{data}\n{after}",excel:'{css}{data}',popup:'Grid Export - © Krajee{msg}'}},o=function(t,o){var n=this,r=o.gridOpts,i=o.genOpts;n.$element=e(t),n.gridId=r.gridId,n.$grid=e("#"+n.gridId),n.dialogLib=o.dialogLib,n.messages=r.messages,n.target=r.target,n.exportConversions=r.exportConversions,n.skipExportElements=r.skipExportElements,n.showConfirmAlert=r.showConfirmAlert,n.action=r.action,n.bom=r.bom,n.encoding=r.encoding,n.module=r.module,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.columns=n.showHeader?"td,th":"td",n.alertMsg=o.alertMsg,n.config=o.config,n.popup="",n.listen()},o.prototype={constructor:o,getArray:function(o){var n=this,r=n.clean(o),i=[],a={};return void 0!==n.config.colHeads&&n.config.colHeads.length>0?i=n.config.colHeads:r.find("thead tr th").each(function(o){var r=e(this).text().trim(),a=t.slug(r);i[o]=!n.config.$h.slugColHeads||t.isEmpty(a)?"col_"+o:a}),r.find('tbody tr:has("td")').each(function(t){a[t]={},e(this).children("td").each(function(o){var n=i[o];a[t][n]=e(this).text().trim()})}),a},setPopupAlert:function(e){var o=this;if(void 0!==o.popup.document)if(arguments.length&&arguments[1]){var n=o.popup.document.getElementsByTagName("body");setTimeout(function(){n[0].innerHTML=e},1200)}else{var r=t.templates.popup.replace("{msg}",e);o.popup.document.write(r)}},processExport:function(e,o){var n=this;setTimeout(function(){t.isEmpty(o)?n[e]():n[e](o)},100)},listenClick:function(e){var o=this,n=arguments.length>1?arguments[1]:"",r=window[o.dialogLib];o.$element.off("click.gridexport").on("click.gridexport",function(i){if(i.stopPropagation(),i.preventDefault(),!o.showConfirmAlert)return void o.processExport(e,n);var a=o.messages,s=t.isEmpty(o.alertMsg)?"":o.alertMsg,l=t.isEmpty(a.allowPopups)?"":a.allowPopups,c=t.isEmpty(a.confirmDownload)?"":a.confirmDownload,p="";return p=s.length&&l.length?s+"\n\n"+l:!s.length&&l.length?l:s.length&&!l.length?s:"",c.length&&(p=p+"\n\n"+c),t.isEmpty(p)?void 0:(r.confirm(p,function(t){t&&o.processExport(e,n),i.preventDefault()}),!1)})},listen:function(){var e=this;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.$element.data("cssStyles")||{},a=n.$table.closest(".kv-grid-container"),s=n.skipExportElements,l=function(e){r.find(e+"."+n.gridId).remove()};s.length&&e.each(s,function(e,t){r.find(t).remove()}),"html"===t&&r.find(".kv-grid-boolean").remove(),o=a.hasClass("kv-grid-wrapper")?a.closest(".floatThead-wrapper").find(".kv-thead-float thead"):a.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("form,input,textarea,select,script").remove(),r.find("[onclick]").removeAttr("onclick"),r.find('a[href*="javascript"]').attr("href","#"),n.showHeader||r.children("thead").remove(),n.showPageSummary||l(".kv-page-summary-container"),n.showFooter||l(".kv-footer-container"),n.showCaption||l(".kv-caption-container"),r.find(".skip-export").remove(),r.find(".skip-export-"+t).remove(),r.find(".strip-tags-export").each(function(){var t=e(this),o=t.text();t.html(o)});var c=r.html();return c=n.preProcess(c,t),r.html(c),e.each(i,function(t,o){r.find(t).each(function(){var t=e(this),n=t.attr("style")||"";e.each(o,function(e,t){n+=e+":"+t+";"}),n&&t.attr("style",n)})}),r},preProcess:function(e,o){var n,r,i,a=this,s=a.exportConversions,l=s.length,c=e,p="from_"+o,d="to_"+o;if(l>0)for(var h=0;l>h;h++)n=s[h],r=void 0!==n[p]?n[p]:void 0!==n.from?n.from:"",i=void 0!==n[d]?n[d]:void 0!==n.to?n.to:"",r.length&&i.length&&(c=t.replaceAll(c,r,i));return c},download:function(o,n){var r,i,a=this,s=a.$element,l=s.attr("data-mime")||"text/plain",c=window.yii,p=s.attr("data-hash")||"",d=s.attr("data-hash-export-config"),h=t.isEmpty(a.config)?{}:a.config,f=a.target,m=function(t,o){return e("",{name:t}).val(o).hide()};"json"===o&&h.jsonReplacer&&delete h.jsonReplacer,r=c?m(c.getCsrfParam()||"_csrf",c.getCsrfToken()||null):null,i="_popup"===f,i&&(f="kvDownloadDialog",a.popup=t.popupDialog("",f,350,120),a.popup.focus(),a.setPopupAlert(a.messages.downloadProgress)),e("",{action:a.action,target:f,method:"post",css:{display:"none"}}).append(m("export_filetype",o),m("export_filename",a.filename)).append(m("export_encoding",a.encoding),m("export_bom",a.bom?1:0)).append(m("export_content",n),m("module_id",a.module),r).append(m("export_mime",l),m("export_hash",p),m("hash_export_config",d)).append(m("export_config",JSON.stringify(h))).appendTo("body").submit().remove(),i&&a.setPopupAlert(a.messages.downloadComplete,!0)},exportHTML:function(){var o,n=this,r=n.clean("html"),i=n.config,a=i.cssFile?i.cssFile:[],s="";o=t.templates.html.replace("{encoding}",n.encoding),e.each(a,function(e,t){s+='\n'}),o=o.replace("{css}",s).replace("{data}",e("").html(r).html()),n.download("html",o)},exportPDF:function(){var o=this,n=o.clean("pdf"),r=t.isEmpty(o.config.contentBefore)?"":o.config.contentBefore,i=t.isEmpty(o.config.contentAfter)?"":o.config.contentAfter,a=o.config.css,s=t.templates.pdf.replace("{css}",a).replace("{before}",r).replace("{after}",i).replace("{data}",e("").html(n).html());o.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),s='"'+o.config.colDelimiter+'"',l='"'+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(l).split(i).join(s)+'"';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 o,n,r=this,i=r.clean("xls"),a=r.config,s=a.cssFile&&r.config.cssFile.length?'':"";i.find("td[data-raw-value]").each(function(){n=e(this),(n.css("mso-number-format")||0===n.css("mso-number-format")||"0"===n.css("mso-number-format"))&&n.html(n.attr("data-raw-value")).removeAttr("data-raw-value")}),o=t.templates.excel.replace("{encoding}",r.encoding).replace("{css}",s).replace("{worksheet}",r.config.worksheet).replace("{data}",e("").html(i).html()).replace(/"/g,"'"),r.download("xls",o)}},e.fn.gridexport=function(t){var n=Array.apply(null,arguments);return n.shift(),this.each(function(){var r=e(this),i=r.data("gridexport"),a="object"==typeof t&&t;i||r.data("gridexport",i=new o(this,e.extend({},e.fn.gridexport.defaults,a,e(this).data()))),"string"==typeof t&&i[t].apply(i,n)})},e.fn.gridexport.defaults={dialogLib:"krajeeDialog"},e.fn.gridexport.Constructor=o}(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 641e7f7f..b4604af4 100644
--- a/src/assets/js/kv-grid-group.js
+++ b/src/assets/js/kv-grid-group.js
@@ -13,18 +13,19 @@
*/
var kvGridGroup;
(function ($) {
- "use strict";
+ 'use strict';
kvGridGroup = function (gridId) {
var $grid, data, groups, $groupRows, i, n, colCount, $pageSum, $firstRow, $lastRow, isEmpty, formatNumber,
calculate, getParentGroup, getLastGroupRow, getCellKey, getCellValue, getSummarySource, getSummaryContent,
- initPageSummary, addRowSpan, adjustLastRow, adjustFooterGroups, createSummary, calculateSummaryContent;
+ initPageSummary, addRowSpan, adjustLastRow, adjustFooterGroups, createSummary, calculateSummaryContent,
+ ROW = 'tr.' + gridId, COL = 'td.' + gridId;
$grid = $('#' + gridId);
data = {};
groups = [];
colCount = 0;
- $pageSum = $grid.find('tr.kv-page-summary');
- $firstRow = $grid.find('tr[data-key]:first');
- $lastRow = $grid.find('tr[data-key]:last');
+ $pageSum = $grid.find(ROW + '.kv-page-summary');
+ $firstRow = $grid.find(ROW + '[data-key]:first');
+ $lastRow = $grid.find(ROW + '[data-key]:last');
isEmpty = function (v) {
return v === undefined || v === null || v.length === 0;
};
@@ -80,7 +81,7 @@ var kvGridGroup;
if (isEmpty(id)) {
return null;
}
- tag = 'td[data-col-seq="' + id + '"]';
+ tag = COL + '[data-col-seq="' + id + '"]';
$tr = $cell.closest('tr');
$td = $tr.find(tag);
i = $td.length;
@@ -102,7 +103,7 @@ var kvGridGroup;
while (i === 0 && $endRow.length) {
$endRow = $tr;
$tr = $tr.next();
- i = $tr.find('td[data-group-key="' + key + '"]').length;
+ i = $tr.find(COL + '[data-group-key="' + key + '"]').length;
}
return $endRow.length ? $endRow : $lastRow;
};
@@ -136,7 +137,7 @@ var kvGridGroup;
j = false;
$row = $row.next(':not(.kv-grid-group-row)');
while (!j && $row.length) {
- $row.find('td[data-col-seq="' + i + '"]').each(function () {
+ $row.find(' > td[data-col-seq="' + i + '"]').each(function () {
data.push(getCellValue($(this), decPoint, thousandSep));
}); // jshint ignore:line
j = $row.hasClass('kv-grid-group-row');
@@ -144,7 +145,7 @@ var kvGridGroup;
}
} else {
while (j <= rowspan && $row.length) {
- $row.find('td[data-col-seq="' + i + '"]').each(function () {
+ $row.find(' > td[data-col-seq="' + i + '"]').each(function () {
data.push(getCellValue($(this), decPoint, thousandSep));
}); // jshint ignore:line
$row = $row.next();
@@ -167,7 +168,7 @@ var kvGridGroup;
if (!$pageSum.length) {
return;
}
- $pageSum.find('td').each(function () {
+ $pageSum.find(' > td').each(function () {
$(this).attr('data-col-seq', i);
i++;
});
@@ -197,7 +198,7 @@ var kvGridGroup;
};
adjustLastRow = function () {
var i, rows = [];
- $lastRow.nextAll('tr.kv-group-footer').each(function () {
+ $lastRow.nextAll(ROW + '.kv-group-footer').each(function () {
rows.push($(this));
});
if (rows.length) {
@@ -206,9 +207,9 @@ var kvGridGroup;
}
}
if ($pageSum.length) {
- $pageSum.find('td').each(function () {
+ $pageSum.find(' > td').each(function () {
var $td = $(this);
- if (!$firstRow.find('td[data-col-seq="' + $td.attr('data-col-seq') + '"]').length) {
+ if (!$firstRow.find(' > td[data-col-seq="' + $td.attr('data-col-seq') + '"]').length) {
$td.remove();
}
});
@@ -216,13 +217,13 @@ var kvGridGroup;
};
adjustFooterGroups = function () {
var len = groups.length, $tbody = $grid.find('tbody:first'), j,
- hasFooter = $tbody.find('tr.kv-group-footer').length;
+ hasFooter = $tbody.find(ROW + '.kv-group-footer').length;
if (len < 3 || !hasFooter) {
return;
}
- $tbody.find(' > tr[data-group-key]').each(function () {
+ $tbody.find(' > ' + ROW + '[data-group-key]').each(function () {
var $row = $(this);
- $row.find('td.kv-grid-group').each(function () {
+ $row.find('> td.kv-grid-group').each(function () {
var $td = $(this), grpSeq = $td.attr('data-sub-group-of') || '0', rowspan = 0, proceed = true;
$row.nextAll().each(function () {
if (!proceed) {
@@ -238,14 +239,14 @@ var kvGridGroup;
}
});
});
- $tbody.find(' > tr.kv-group-footer').each(function () {
+ $tbody.find(' > ' + ROW + '.kv-group-footer').each(function () {
var $tr = $(this), i = parseInt($tr.attr('data-group-seq') || 0);
for (j = 1; j <= i; j++) {
- $tr.find('td[data-summary-col-seq=' + j + ']').remove();
+ $tr.find('> td[data-summary-col-seq=' + j + ']').remove();
}
});
// summary correction for multi group footers
- $tbody.find(' > tr.kv-group-footer > td').each(function () {
+ $tbody.find(' > ' + ROW + '.kv-group-footer > td').each(function () {
var $td = $(this), sumData = $td.data('groupSummary') || null, config, data = [], seq, grpSeq,
$tr, proceed = true, out;
if (!sumData) {
@@ -259,13 +260,14 @@ var kvGridGroup;
seq = $td.attr('data-summary-col-seq');
$tr = $td.closest('tr');
grpSeq = $tr.attr('data-group-seq');
- $tr.prevAll().each(function () {
+ $tr.prevAll('.' + gridId).each(function () {
var $row = $(this), i = $row.attr('data-group-seq') || '-1', content;
if (!proceed) {
return;
}
// noinspection JSUnresolvedVariable
- content = getCellValue($row.find('td[data-col-seq=' + seq + ']'), config.decPoint, config.thousandSep);
+ content = getCellValue($row.find('> td[data-col-seq=' + seq + ']'), config.decPoint,
+ config.thousandSep);
data.push(content);
if (i === grpSeq) {
proceed = false;
@@ -289,17 +291,17 @@ var kvGridGroup;
$parent = $cell.attr('data-sub-group-of') ? getParentGroup($cell) : null;
isGroupedRow = $parent && $parent.length && $parent.is('[data-grouped-row]');
key = $parent && $parent.length ? $parent.attr('data-col-seq') : null;
- $row = $(document.createElement('tr'));
+ $row = $(document.createElement('tr')).addClass(gridId);
if (data.options) {
$row.attr(data.options);
}
- $row.addClass(css).attr({'data-group-seq': key || '0'});
- $firstRow.find('td').each(function () {
+ $row.addClass(css).addClass(gridId).attr({'data-group-seq': key || '0'});
+ $firstRow.find('> td').each(function () {
var summary;
$td = $(this);
i = $td.attr('data-col-seq');
if (!key || i !== key || isGroupedRow) { // jshint ignore:line
- $col = $(document.createElement('td')).attr('data-summary-col-seq', i);
+ $col = $(document.createElement('td')).addClass(gridId).attr('data-summary-col-seq', i);
if (data.content && data.content[i]) {
// noinspection JSUnresolvedVariable
config = data.contentFormats && data.contentFormats[i] || {};
@@ -325,8 +327,8 @@ var kvGridGroup;
}
if (type === 'groupHeader') {
$tr.before($row);
- if ($tr.find('td[data-col-seq="' + key + '"]').length) {
- $row.find('td').each(function () {
+ if ($tr.find('> td[data-col-seq="' + key + '"]').length) {
+ $row.find(' > td').each(function () {
var $td = $(this), seq = parseInt($td.attr('data-summary-col-seq'));
key = parseInt(key);
if (seq === key - 1) {
@@ -357,7 +359,7 @@ var kvGridGroup;
if (!(from > -1 && to > -1)) {
return;
}
- $row.find('td').each(function () {
+ $row.find(' > td').each(function () {
var $td = $(this);
j = $td.attr('data-summary-col-seq');
if (j >= from && j <= to) {
@@ -365,7 +367,7 @@ var kvGridGroup;
cspan++;
}
});
- $row.find('td').each(function () {
+ $row.find(' > td').each(function () {
var $td = $(this);
j = parseInt($td.attr('data-summary-col-seq') || -1);
if (j > from && j <= to) {
@@ -380,7 +382,7 @@ var kvGridGroup;
}
};
initPageSummary();
- $grid.find('td.kv-grid-group').each(function () {
+ $grid.find(ROW + '> td.kv-grid-group').each(function () {
var $cell = $(this), key = $(this).attr('data-group-key');
if (!key) {
return;
@@ -412,52 +414,53 @@ var kvGridGroup;
cellKeyPrev = cellKeyCurr;
});
});
- $grid.find('td.kv-grid-group.kv-temp-cells').remove();
+ $grid.find(ROW + '> td.kv-grid-group.kv-temp-cells').remove();
$.each(groups, function (i, g) {
var seq = 0;
- $grid.find('td[data-group-key="' + g + '"]').each(function () {
+ $grid.find(ROW + '> td[data-group-key="' + g + '"]').each(function () {
var $cell = $(this), $tr, css = seq % 2 > 0 ? $cell.attr('data-odd-css') : $cell.attr('data-even-css');
if (css) {
$cell.removeClass(css).addClass(css);
}
if ($cell.is('[data-grouped-row]')) {
- $tr = $(document.createElement('tr')).addClass('kv-grid-group-row');
+ $tr = $(document.createElement('tr')).addClass('kv-grid-group-row ' + gridId);
$cell.closest('tr').before($tr);
$cell.removeAttr('rowspan').appendTo($tr).css('width', 'auto');
}
seq++;
});
});
- $groupRows = $grid.find('tr.kv-grid-group-row');
+ $groupRows = $grid.find(ROW + '.kv-grid-group-row');
if ($groupRows.length) {
- colCount = $grid.find('tr[data-key]:first > td').length;
+ colCount = $grid.find(ROW + '[data-key]:first > td').length;
if (colCount) {
$groupRows.each(function () {
$(this).find('>td').attr('colspan', colCount);
});
}
- $groupRows.find('td[data-group-key]').each(function () {
- var gkey = $(this).data('groupKey'),
- $head = $grid.find('.kv-grid-group-header[data-group-key]'),
- $filt = $grid.find('.kv-grid-group-filter[data-group-key]');
+ $groupRows.find('> td[data-group-key]').each(function () {
+ var HDR = '.' + gridId + '.kv-grid-group-header', FIL = '.' + gridId + '.kv-grid-group-filter',
+ gkey = $(this).data('groupKey'),
+ $head = $grid.find(HDR + '[data-group-key]'),
+ $filt = $grid.find(FIL + '[data-group-key]');
$(this).closest('tr').data('groupKey', gkey);
if ($head.length) {
- $grid.find('.kv-grid-group-header[data-group-key="' + gkey + '"]').remove();
+ $grid.find(HDR + '[data-group-key="' + gkey + '"]').remove();
}
if ($filt.length) {
- $grid.find('.kv-grid-group-filter[data-group-key="' + gkey + '"]').remove();
+ $grid.find(FIL + '[data-group-key="' + gkey + '"]').remove();
}
});
}
$lastRow.attr('data-last-row', 1);
n = groups.length - 1;
for (i = n; i >= 0; i--) {
- $grid.find('td[data-group-key="' + groups[i] + '"]').each(function () {
+ $grid.find(ROW + '> td[data-group-key="' + groups[i] + '"]').each(function () {
createSummary($(this), 'groupFooter');
}); // jshint ignore:line
}
for (i = 0; i <= n; i++) {
- $grid.find('td[data-group-key="' + groups[i] + '"]').each(function () {
+ $grid.find(ROW + '> td[data-group-key="' + groups[i] + '"]').each(function () {
createSummary($(this), 'groupHeader');
}); // jshint ignore:line
}
diff --git a/src/assets/js/kv-grid-group.min.js b/src/assets/js/kv-grid-group.min.js
index 06cae468..1e6c2671 100644
--- a/src/assets/js/kv-grid-group.min.js
+++ b/src/assets/js/kv-grid-group.min.js
@@ -10,5 +10,4 @@
* Copyright: 2014 - 2019, Kartik Visweswaran, Krajee.com
* For more JQuery plugins visit http://plugins.krajee.com
* For more Yii related demos visit http://demos.krajee.com
- */
-var kvGridGroup;!function(t){"use strict";kvGridGroup=function(a){var r,e,n,o,d,i,u,s,c,f,l,p,g,h,v,m,k,y,w,q,x,b,C,A,F;for(r=t("#"+a),e={},n=[],u=0,s=r.find("tr.kv-page-summary"),c=r.find("tr[data-key]:first"),f=r.find("tr[data-key]:last"),l=function(t){return void 0===t||null===t||0===t.length},p=function(t,a,r,e,n){var o,d="\\d(?=(\\d{"+(n||3)+"})+"+(a>0?"\\D":"$")+")",i=parseFloat(t),u=parseInt(a);return isNaN(i)?"":(o=i+"",r=r||".",e=e||",",-1===o.indexOf(".")&&u>0&&(i=parseFloat(i+".0")),o=i.toFixed(isNaN(u)||0>u?0:u),o=o.replace(".",r),o.replace(new RegExp(d,"g"),"$&"+e))},g=function(t,a){var r,e,n=0,o=t&&t.length||0;if(!o)return"";switch(a){case"f_count":return o;case"f_sum":case"f_avg":for(r=0;o>r;r++)n+=t[r];return"f_sum"===a?n:n/o;case"f_max":case"f_min":return e="f_max"===a?"max":"min",Math[e].apply(null,t);default:return""}},h=function(t){var a,r,e,n,o=t.attr("data-sub-group-of");if(l(o))return null;if(n='td[data-col-seq="'+o+'"]',a=t.closest("tr"),r=a.find(n),e=r.length,e>0)return r;for(;0===e&&a.length;)a=a.prev(),r=a.find(n),e=r.length;return 0===e?null:r},v=function(t,a){var r=t.attr("data-group-key"),e=0,n=a;if(a.attr("data-last-row"))return a;for(;0===e&&n.length;)n=a,a=a.next(),e=a.find('td[data-group-key="'+r+'"]').length;return n.length?n:f},m=function(t){for(var a=t,r="";a&&a.length;)r+=a.text().trim(),a=h(a);return r},k=function(t,a,r){var e;return t&&t.length?(t.is("[data-raw-value]")?e=t.attr("data-raw-value"):(e=t.text().split(r||",").join(""),a&&"."!==a&&(e=e.replace(a,"."))),e?parseFloat(e):0):0},y=function(a,r,e,n,o){var d=1,i=[],u=a,s=u.hasClass("kv-grid-group-row"),c=r.attr("rowspan")||1;if(s)for(d=!1,u=u.next(":not(.kv-grid-group-row)");!d&&u.length;)u.find('td[data-col-seq="'+e+'"]').each(function(){i.push(k(t(this),n,o))}),d=u.hasClass("kv-grid-group-row"),u=u.next();else for(;c>=d&&u.length;)u.find('td[data-col-seq="'+e+'"]').each(function(){i.push(k(t(this),n,o))}),u=u.next(),d++;return i},w=function(t,a,r,e,n){var o=n.format||"",d=n.func?window[n.func]:"",i=n.decPoint||".",u=n.thousandSep||",",s="number"===o||"callback"===o&&"function"==typeof d?y(a,r,e,i,u):t;return F(t,s,n)},q=function(){var a=0;s.length&&s.find("td").each(function(){t(this).attr("data-col-seq",a),a++})},F=function(t,a,r){var e,n=r.decimals||0,o=r.decPoint||".",d=r.thousandSep||",",i=r.format||"",u=r.func?window[r.func]:"";return"number"===i?(e=g(a,t),p(e,n,o,d)):"callback"===i&&"function"==typeof u?u(a):t},x=function(t,a){if(!t[0].hasAttribute("data-grouped-row")){a=a||1;var r=t.attr("rowspan")||1;r=parseInt(r)+a,t.attr("rowspan",r)}},b=function(){var a,r=[];if(f.nextAll("tr.kv-group-footer").each(function(){r.push(t(this))}),r.length)for(a=0;ae||!d||(o.find(" > tr[data-group-key]").each(function(){var a=t(this);a.find("td.kv-grid-group").each(function(){var r=t(this),e=r.attr("data-sub-group-of")||"0",n=0,o=!0;a.nextAll().each(function(){o&&(n++,t(this).attr("data-group-seq")===e&&(o=!1))}),r[0].hasAttribute("data-grouped-row")||r.attr("rowspan",n)})}),o.find(" > tr.kv-group-footer").each(function(){var r=t(this),e=parseInt(r.attr("data-group-seq")||0);for(a=1;e>=a;a++)r.find("td[data-summary-col-seq="+a+"]").remove()}),o.find(" > tr.kv-group-footer > td").each(function(){var a,r,e,n,o,d=t(this),i=d.data("groupSummary")||null,u=[],s=!0;i&&(a=i.config,(a.format||a.func)&&(r=d.attr("data-summary-col-seq"),n=d.closest("tr"),e=n.attr("data-group-seq"),n.prevAll().each(function(){var n,o=t(this),d=o.attr("data-group-seq")||"-1";s&&(n=k(o.find("td[data-col-seq="+r+"]"),a.decPoint,a.thousandSep),u.push(n),d===e&&(s=!1))}),o=F(i.source||"",u,a),d.html(o)))}))},A=function(a,r){var e,o,d,i,u,s,f,l,p,g,m,k=a.data(r),y=!1,q="groupHeader"===r?"kv-group-header":"kv-group-footer";k&&(o=a.attr("data-group-key"),d=a.closest("tr"),o&&d.attr("data-group-key",o),e=a.attr("data-sub-group-of")?h(a):null,y=e&&e.length&&e.is("[data-grouped-row]"),o=e&&e.length?e.attr("data-col-seq"):null,f=t(document.createElement("tr")),k.options&&f.attr(k.options),f.addClass(q).attr({"data-group-seq":o||"0"}),c.find("td").each(function(){var r;i=t(this),u=i.attr("data-col-seq"),o&&u===o&&!y||(l=t(document.createElement("td")).attr("data-summary-col-seq",u),k.content&&k.content[u]&&(m=k.contentFormats&&k.contentFormats[u]||{},g=w(k.content[u],d,a,u,m),r={source:k.content[u],config:m},l.html(g).data("groupSummary",r)),k.contentOptions&&k.contentOptions[u]&&l.attr(k.contentOptions[u]),i.hasClass("kv-grid-hide")&&l.addClass("kv-grid-hide"),i.hasClass("skip-export")&&l.addClass("skip-export"),l.appendTo(f))}),e&&e.length&&!y&&n.length<3&&x(e),"groupHeader"===r?(d.before(f),d.find('td[data-col-seq="'+o+'"]').length&&f.find("td").each(function(){var a=t(this),r=parseInt(a.attr("data-summary-col-seq"));return o=parseInt(o),r===o-1?void a.after(e):r===o+1?void a.before(e):void(r>o&&a.before(e))})):(p=v(a,d),y&&p.hasClass("kv-grid-group-row")?p.before(f):p.after(f)),k.mergeColumns&&k.mergeColumns.length&&t.each(k.mergeColumns,function(a,r){var e=r[0],n=r[1],o=0,d="";e>-1&&n>-1&&(f.find("td").each(function(){var a=t(this);s=a.attr("data-summary-col-seq"),s>=e&&n>=s&&(d+=a.html(),o++)}),f.find("td").each(function(){var a=t(this);s=parseInt(a.attr("data-summary-col-seq")||-1),s>e&&n>=s?a.remove():s===e&&a.attr("colspan",o).html(d)}))}))},q(),r.find("td.kv-grid-group").each(function(){var a=t(this),r=t(this).attr("data-group-key");r&&(t.inArray(r,n)<0&&n.push(r),void 0===e[r]?e[r]=[a]:e[r].push(a))}),t.each(n,function(a,r){var n,o=e[r],d=1,i=0,u="",s="";t.each(o,function(t,r){n=o[i],s=a>0?m(r):r.text().trim(),s===u?(d++,n[0].hasAttribute("data-grouped-row")||n.attr("rowspan",d),r.addClass("kv-temp-cells").hide()):(i=t,d=1),u=s})}),r.find("td.kv-grid-group.kv-temp-cells").remove(),t.each(n,function(a,e){var n=0;r.find('td[data-group-key="'+e+'"]').each(function(){var a,r=t(this),e=n%2>0?r.attr("data-odd-css"):r.attr("data-even-css");e&&r.removeClass(e).addClass(e),r.is("[data-grouped-row]")&&(a=t(document.createElement("tr")).addClass("kv-grid-group-row"),r.closest("tr").before(a),r.removeAttr("rowspan").appendTo(a).css("width","auto")),n++})}),o=r.find("tr.kv-grid-group-row"),o.length&&(u=r.find("tr[data-key]:first > td").length,u&&o.each(function(){t(this).find(">td").attr("colspan",u)}),o.find("td[data-group-key]").each(function(){var a=t(this).data("groupKey"),e=r.find(".kv-grid-group-header[data-group-key]"),n=r.find(".kv-grid-group-filter[data-group-key]");t(this).closest("tr").data("groupKey",a),e.length&&r.find('.kv-grid-group-header[data-group-key="'+a+'"]').remove(),n.length&&r.find('.kv-grid-group-filter[data-group-key="'+a+'"]').remove()})),f.attr("data-last-row",1),i=n.length-1,d=i;d>=0;d--)r.find('td[data-group-key="'+n[d]+'"]').each(function(){A(t(this),"groupFooter")});for(d=0;i>=d;d++)r.find('td[data-group-key="'+n[d]+'"]').each(function(){A(t(this),"groupHeader")});b(),C()}}(window.jQuery);
\ No newline at end of file
+ */var kvGridGroup;!function(t){"use strict";kvGridGroup=function(a){var r,e,n,o,d,i,s,u,c,f,l,h,p,g,v,m,k,y,w,q,C,x,b,A,F,_="tr."+a,I="td."+a;for(r=t("#"+a),e={},n=[],s=0,u=r.find(_+".kv-page-summary"),c=r.find(_+"[data-key]:first"),f=r.find(_+"[data-key]:last"),l=function(t){return void 0===t||null===t||0===t.length},h=function(t,a,r,e,n){var o,d="\\d(?=(\\d{"+(n||3)+"})+"+(a>0?"\\D":"$")+")",i=parseFloat(t),s=parseInt(a);return isNaN(i)?"":(o=i+"",r=r||".",e=e||",",-1===o.indexOf(".")&&s>0&&(i=parseFloat(i+".0")),o=i.toFixed(isNaN(s)||0>s?0:s),o=o.replace(".",r),o.replace(new RegExp(d,"g"),"$&"+e))},p=function(t,a){var r,e,n=0,o=t&&t.length||0;if(!o)return"";switch(a){case"f_count":return o;case"f_sum":case"f_avg":for(r=0;o>r;r++)n+=t[r];return"f_sum"===a?n:n/o;case"f_max":case"f_min":return e="f_max"===a?"max":"min",Math[e].apply(null,t);default:return""}},g=function(t){var a,r,e,n,o=t.attr("data-sub-group-of");if(l(o))return null;if(n=I+'[data-col-seq="'+o+'"]',a=t.closest("tr"),r=a.find(n),e=r.length,e>0)return r;for(;0===e&&a.length;)a=a.prev(),r=a.find(n),e=r.length;return 0===e?null:r},v=function(t,a){var r=t.attr("data-group-key"),e=0,n=a;if(a.attr("data-last-row"))return a;for(;0===e&&n.length;)n=a,a=a.next(),e=a.find(I+'[data-group-key="'+r+'"]').length;return n.length?n:f},m=function(t){for(var a=t,r="";a&&a.length;)r+=a.text().trim(),a=g(a);return r},k=function(t,a,r){var e;return t&&t.length?(t.is("[data-raw-value]")?e=t.attr("data-raw-value"):(e=t.text().split(r||",").join(""),a&&"."!==a&&(e=e.replace(a,"."))),e?parseFloat(e):0):0},y=function(a,r,e,n,o){var d=1,i=[],s=a,u=s.hasClass("kv-grid-group-row"),c=r.attr("rowspan")||1;if(u)for(d=!1,s=s.next(":not(.kv-grid-group-row)");!d&&s.length;)s.find(' > td[data-col-seq="'+e+'"]').each(function(){i.push(k(t(this),n,o))}),d=s.hasClass("kv-grid-group-row"),s=s.next();else for(;c>=d&&s.length;)s.find(' > td[data-col-seq="'+e+'"]').each(function(){i.push(k(t(this),n,o))}),s=s.next(),d++;return i},w=function(t,a,r,e,n){var o=n.format||"",d=n.func?window[n.func]:"",i=n.decPoint||".",s=n.thousandSep||",",u="number"===o||"callback"===o&&"function"==typeof d?y(a,r,e,i,s):t;return F(t,u,n)},q=function(){var a=0;u.length&&u.find(" > td").each(function(){t(this).attr("data-col-seq",a),a++})},F=function(t,a,r){var e,n=r.decimals||0,o=r.decPoint||".",d=r.thousandSep||",",i=r.format||"",s=r.func?window[r.func]:"";return"number"===i?(e=p(a,t),h(e,n,o,d)):"callback"===i&&"function"==typeof s?s(a):t},C=function(t,a){if(!t[0].hasAttribute("data-grouped-row")){a=a||1;var r=t.attr("rowspan")||1;r=parseInt(r)+a,t.attr("rowspan",r)}},x=function(){var a,r=[];if(f.nextAll(_+".kv-group-footer").each(function(){r.push(t(this))}),r.length)for(a=0;a td").each(function(){var a=t(this);c.find(' > td[data-col-seq="'+a.attr("data-col-seq")+'"]').length||a.remove()})},b=function(){var e,o=n.length,d=r.find("tbody:first"),i=d.find(_+".kv-group-footer").length;3>o||!i||(d.find(" > "+_+"[data-group-key]").each(function(){var a=t(this);a.find("> td.kv-grid-group").each(function(){var r=t(this),e=r.attr("data-sub-group-of")||"0",n=0,o=!0;a.nextAll().each(function(){o&&(n++,t(this).attr("data-group-seq")===e&&(o=!1))}),r[0].hasAttribute("data-grouped-row")||r.attr("rowspan",n)})}),d.find(" > "+_+".kv-group-footer").each(function(){var a=t(this),r=parseInt(a.attr("data-group-seq")||0);for(e=1;r>=e;e++)a.find("> td[data-summary-col-seq="+e+"]").remove()}),d.find(" > "+_+".kv-group-footer > td").each(function(){var r,e,n,o,d,i=t(this),s=i.data("groupSummary")||null,u=[],c=!0;s&&(r=s.config,(r.format||r.func)&&(e=i.attr("data-summary-col-seq"),o=i.closest("tr"),n=o.attr("data-group-seq"),o.prevAll("."+a).each(function(){var a,o=t(this),d=o.attr("data-group-seq")||"-1";c&&(a=k(o.find("> td[data-col-seq="+e+"]"),r.decPoint,r.thousandSep),u.push(a),d===n&&(c=!1))}),d=F(s.source||"",u,r),i.html(d)))}))},A=function(r,e){var o,d,i,s,u,f,l,h,p,m,k,y=r.data(e),q=!1,x="groupHeader"===e?"kv-group-header":"kv-group-footer";y&&(d=r.attr("data-group-key"),i=r.closest("tr"),d&&i.attr("data-group-key",d),o=r.attr("data-sub-group-of")?g(r):null,q=o&&o.length&&o.is("[data-grouped-row]"),d=o&&o.length?o.attr("data-col-seq"):null,l=t(document.createElement("tr")).addClass(a),y.options&&l.attr(y.options),l.addClass(x).addClass(a).attr({"data-group-seq":d||"0"}),c.find("> td").each(function(){var e;s=t(this),u=s.attr("data-col-seq"),d&&u===d&&!q||(h=t(document.createElement("td")).addClass(a).attr("data-summary-col-seq",u),y.content&&y.content[u]&&(k=y.contentFormats&&y.contentFormats[u]||{},m=w(y.content[u],i,r,u,k),e={source:y.content[u],config:k},h.html(m).data("groupSummary",e)),y.contentOptions&&y.contentOptions[u]&&h.attr(y.contentOptions[u]),s.hasClass("kv-grid-hide")&&h.addClass("kv-grid-hide"),s.hasClass("skip-export")&&h.addClass("skip-export"),h.appendTo(l))}),o&&o.length&&!q&&n.length<3&&C(o),"groupHeader"===e?(i.before(l),i.find('> td[data-col-seq="'+d+'"]').length&&l.find(" > td").each(function(){var a=t(this),r=parseInt(a.attr("data-summary-col-seq"));return d=parseInt(d),r===d-1?void a.after(o):r===d+1?void a.before(o):void(r>d&&a.before(o))})):(p=v(r,i),q&&p.hasClass("kv-grid-group-row")?p.before(l):p.after(l)),y.mergeColumns&&y.mergeColumns.length&&t.each(y.mergeColumns,function(a,r){var e=r[0],n=r[1],o=0,d="";e>-1&&n>-1&&(l.find(" > td").each(function(){var a=t(this);f=a.attr("data-summary-col-seq"),f>=e&&n>=f&&(d+=a.html(),o++)}),l.find(" > td").each(function(){var a=t(this);f=parseInt(a.attr("data-summary-col-seq")||-1),f>e&&n>=f?a.remove():f===e&&a.attr("colspan",o).html(d)}))}))},q(),r.find(_+"> td.kv-grid-group").each(function(){var a=t(this),r=t(this).attr("data-group-key");r&&(t.inArray(r,n)<0&&n.push(r),void 0===e[r]?e[r]=[a]:e[r].push(a))}),t.each(n,function(a,r){var n,o=e[r],d=1,i=0,s="",u="";t.each(o,function(t,r){n=o[i],u=a>0?m(r):r.text().trim(),u===s?(d++,n[0].hasAttribute("data-grouped-row")||n.attr("rowspan",d),r.addClass("kv-temp-cells").hide()):(i=t,d=1),s=u})}),r.find(_+"> td.kv-grid-group.kv-temp-cells").remove(),t.each(n,function(e,n){var o=0;r.find(_+'> td[data-group-key="'+n+'"]').each(function(){var r,e=t(this),n=o%2>0?e.attr("data-odd-css"):e.attr("data-even-css");n&&e.removeClass(n).addClass(n),e.is("[data-grouped-row]")&&(r=t(document.createElement("tr")).addClass("kv-grid-group-row "+a),e.closest("tr").before(r),e.removeAttr("rowspan").appendTo(r).css("width","auto")),o++})}),o=r.find(_+".kv-grid-group-row"),o.length&&(s=r.find(_+"[data-key]:first > td").length,s&&o.each(function(){t(this).find(">td").attr("colspan",s)}),o.find("> td[data-group-key]").each(function(){var e="."+a+".kv-grid-group-header",n="."+a+".kv-grid-group-filter",o=t(this).data("groupKey"),d=r.find(e+"[data-group-key]"),i=r.find(n+"[data-group-key]");t(this).closest("tr").data("groupKey",o),d.length&&r.find(e+'[data-group-key="'+o+'"]').remove(),i.length&&r.find(n+'[data-group-key="'+o+'"]').remove()})),f.attr("data-last-row",1),i=n.length-1,d=i;d>=0;d--)r.find(_+'> td[data-group-key="'+n[d]+'"]').each(function(){A(t(this),"groupFooter")});for(d=0;i>=d;d++)r.find(_+'> td[data-group-key="'+n[d]+'"]').each(function(){A(t(this),"groupHeader")});x(),b()}}(window.jQuery);
\ No newline at end of file
|