datatables.net-rowgroup
Advanced tools
Comparing version 1.4.1 to 1.5.0
@@ -1,2 +0,2 @@ | ||
/*! RowGroup 1.4.1 | ||
/*! RowGroup 1.5.0 | ||
* © SpryMedia Ltd - datatables.net/license | ||
@@ -46,3 +46,3 @@ */ | ||
} | ||
}(function( $, window, document, undefined ) { | ||
}(function( $, window, document ) { | ||
'use strict'; | ||
@@ -56,3 +56,3 @@ var DataTable = $.fn.dataTable; | ||
* @description RowGrouping for DataTables | ||
* @version 1.4.1 | ||
* @version 1.5.0 | ||
* @author SpryMedia Ltd (www.sprymedia.co.uk) | ||
@@ -74,4 +74,4 @@ * @contact datatables.net | ||
// Sanity check that we are using DataTables 1.10 or newer | ||
if (!DataTable.versionCheck || !DataTable.versionCheck('1.10.8')) { | ||
throw 'RowGroup requires DataTables 1.10.8 or newer'; | ||
if (!DataTable.versionCheck || !DataTable.versionCheck('1.11')) { | ||
throw 'RowGroup requires DataTables 1.11 or newer'; | ||
} | ||
@@ -239,13 +239,15 @@ | ||
var fns = Array.isArray(this.c.dataSrc) ? this.c.dataSrc : [this.c.dataSrc]; | ||
var fn = DataTable.ext.oApi._fnGetObjectDataFn(fns[level]); | ||
var fn = DataTable.util.get(fns[level]); | ||
var dt = this.s.dt; | ||
var group, last; | ||
var i, ien; | ||
var data = []; | ||
var that = this; | ||
for (var i = 0, ien = rows.length; i < ien; i++) { | ||
for (i = 0, ien = rows.length; i < ien; i++) { | ||
var rowIndex = rows[i]; | ||
var rowData = dt.row(rowIndex).data(); | ||
var group = fn(rowData); | ||
group = fn(rowData, level); | ||
if (group === null || group === undefined) { | ||
@@ -268,3 +270,3 @@ group = that.c.emptyDataGroup; | ||
if (fns[level + 1] !== undefined) { | ||
for (var i = 0, ien = data.length; i < ien; i++) { | ||
for (i = 0, ien = data.length; i < ien; i++) { | ||
data[i].children = this._group(level + 1, data[i].rows); | ||
@@ -424,3 +426,3 @@ } | ||
RowGroup.version = '1.4.1'; | ||
RowGroup.version = '1.5.0'; | ||
@@ -427,0 +429,0 @@ $.fn.dataTable.RowGroup = RowGroup; |
@@ -1,4 +0,4 @@ | ||
/*! RowGroup 1.4.1 | ||
/*! RowGroup 1.5.0 | ||
* © SpryMedia Ltd - datatables.net/license | ||
*/ | ||
!function(e){var n,o;"function"==typeof define&&define.amd?define(["jquery","datatables.net"],function(t){return e(t,window,document)}):"object"==typeof exports?(n=require("jquery"),o=function(t,r){r.fn.dataTable||require("datatables.net")(t,r)},"undefined"==typeof window?module.exports=function(t,r){return t=t||window,r=r||n(t),o(t,r),e(r,0,t.document)}:(o(window,n),module.exports=e(n,window,window.document))):e(jQuery,window,document)}(function(o,t,r,l){"use strict";function a(t,r){if(!p.versionCheck||!p.versionCheck("1.10.8"))throw"RowGroup requires DataTables 1.10.8 or newer";if(this.c=o.extend(!0,{},p.defaults.rowGroup,a.defaults,r),this.s={dt:new p.Api(t)},this.dom={},r=this.s.dt.settings()[0],t=r.rowGroup)return t;(r.rowGroup=this)._constructor()}var p=o.fn.dataTable;return o.extend(a.prototype,{dataSrc:function(t){var r;return t===l?this.c.dataSrc:(r=this.s.dt,this.c.dataSrc=t,o(r.table().node()).triggerHandler("rowgroup-datasrc.dt",[r,t]),this)},disable:function(){return this.c.enable=!1,this},enable:function(t){return!1===t?this.disable():(this.c.enable=!0,this)},enabled:function(){return this.c.enable},_constructor:function(){var e=this,t=this.s.dt,n=t.settings()[0];t.on("draw.dtrg",function(t,r){e.c.enable&&n===r&&e._draw()}),t.on("column-visibility.dt.dtrg responsive-resize.dt.dtrg",function(){e._adjustColspan()}),t.on("destroy",function(){t.off(".dtrg")})},_adjustColspan:function(){o("tr."+this.c.className,this.s.dt.table().body()).find("th:visible, td:visible").attr("colspan",this._colspan())},_colspan:function(){return this.s.dt.columns().visible().reduce(function(t,r){return t+r},0)},_draw:function(){var t=this.s.dt,t=this._group(0,t.rows({page:"current"}).indexes());this._groupDisplay(0,t)},_group:function(t,r){for(var e,n=Array.isArray(this.c.dataSrc)?this.c.dataSrc:[this.c.dataSrc],o=p.ext.oApi._fnGetObjectDataFn(n[t]),a=this.s.dt,s=[],i=0,u=r.length;i<u;i++){var d,c=r[i];null!==(d=o(a.row(c).data()))&&d!==l||(d=this.c.emptyDataGroup),e!==l&&d===e||(s.push({dataPoint:d,rows:[]}),e=d),s[s.length-1].rows.push(c)}if(n[t+1]!==l)for(i=0,u=s.length;i<u;i++)s[i].children=this._group(t+1,s[i].rows);return s},_groupDisplay:function(t,r){for(var e,n=this.s.dt,o=0,a=r.length;o<a;o++){var s,i=r[o],u=i.dataPoint,d=i.rows;this.c.startRender&&(e=this.c.startRender.call(this,n.rows(d),u,t),(s=this._rowWrap(e,this.c.startClassName,t))&&s.insertBefore(n.row(d[0]).node())),this.c.endRender&&(e=this.c.endRender.call(this,n.rows(d),u,t),(s=this._rowWrap(e,this.c.endClassName,t))&&s.insertAfter(n.row(d[d.length-1]).node())),i.children&&this._groupDisplay(t+1,i.children)}},_rowWrap:function(t,r,e){return(t=null!==t&&""!==t?t:this.c.emptyDataGroup)===l||null===t?null:("object"==typeof t&&t.nodeName&&"tr"===t.nodeName.toLowerCase()?o(t):t instanceof o&&t.length&&"tr"===t[0].nodeName.toLowerCase()?t:o("<tr/>").append(o("<th/>").attr("colspan",this._colspan()).attr("scope","row").append(t))).addClass(this.c.className).addClass(r).addClass("dtrg-level-"+e)}}),a.defaults={className:"dtrg-group",dataSrc:0,emptyDataGroup:"No group",enable:!0,endClassName:"dtrg-end",endRender:null,startClassName:"dtrg-start",startRender:function(t,r){return r}},a.version="1.4.1",o.fn.dataTable.RowGroup=a,o.fn.DataTable.RowGroup=a,p.Api.register("rowGroup()",function(){return this}),p.Api.register("rowGroup().disable()",function(){return this.iterator("table",function(t){t.rowGroup&&t.rowGroup.enable(!1)})}),p.Api.register("rowGroup().enable()",function(r){return this.iterator("table",function(t){t.rowGroup&&t.rowGroup.enable(r===l||r)})}),p.Api.register("rowGroup().enabled()",function(){var t=this.context;return!(!t.length||!t[0].rowGroup)&&t[0].rowGroup.enabled()}),p.Api.register("rowGroup().dataSrc()",function(r){return r===l?this.context[0].rowGroup.dataSrc():this.iterator("table",function(t){t.rowGroup&&t.rowGroup.dataSrc(r)})}),o(r).on("preInit.dt.dtrg",function(t,r,e){var n;"dt"===t.namespace&&(t=r.oInit.rowGroup,n=p.defaults.rowGroup,(t||n)&&(n=o.extend({},n,t),!1!==t&&new a(r,n)))}),p}); | ||
!function(e){var n,o;"function"==typeof define&&define.amd?define(["jquery","datatables.net"],function(t){return e(t,window,document)}):"object"==typeof exports?(n=require("jquery"),o=function(t,r){r.fn.dataTable||require("datatables.net")(t,r)},"undefined"==typeof window?module.exports=function(t,r){return t=t||window,r=r||n(t),o(t,r),e(r,0,t.document)}:(o(window,n),module.exports=e(n,window,window.document))):e(jQuery,window,document)}(function(i,t,r){"use strict";function a(t,r){if(!l.versionCheck||!l.versionCheck("1.11"))throw"RowGroup requires DataTables 1.11 or newer";if(this.c=i.extend(!0,{},l.defaults.rowGroup,a.defaults,r),this.s={dt:new l.Api(t)},this.dom={},r=this.s.dt.settings()[0],t=r.rowGroup)return t;(r.rowGroup=this)._constructor()}var l=i.fn.dataTable;return i.extend(a.prototype,{dataSrc:function(t){var r;return void 0===t?this.c.dataSrc:(r=this.s.dt,this.c.dataSrc=t,i(r.table().node()).triggerHandler("rowgroup-datasrc.dt",[r,t]),this)},disable:function(){return this.c.enable=!1,this},enable:function(t){return!1===t?this.disable():(this.c.enable=!0,this)},enabled:function(){return this.c.enable},_constructor:function(){var e=this,t=this.s.dt,n=t.settings()[0];t.on("draw.dtrg",function(t,r){e.c.enable&&n===r&&e._draw()}),t.on("column-visibility.dt.dtrg responsive-resize.dt.dtrg",function(){e._adjustColspan()}),t.on("destroy",function(){t.off(".dtrg")})},_adjustColspan:function(){i("tr."+this.c.className,this.s.dt.table().body()).find("th:visible, td:visible").attr("colspan",this._colspan())},_colspan:function(){return this.s.dt.columns().visible().reduce(function(t,r){return t+r},0)},_draw:function(){var t=this.s.dt,t=this._group(0,t.rows({page:"current"}).indexes());this._groupDisplay(0,t)},_group:function(t,r){for(var e,n=Array.isArray(this.c.dataSrc)?this.c.dataSrc:[this.c.dataSrc],o=l.util.get(n[t]),i=this.s.dt,a=[],s=0,d=r.length;s<d;s++){var u,c=r[s];null==(u=o(i.row(c).data(),t))&&(u=this.c.emptyDataGroup),void 0!==e&&u===e||(a.push({dataPoint:u,rows:[]}),e=u),a[a.length-1].rows.push(c)}if(void 0!==n[t+1])for(s=0,d=a.length;s<d;s++)a[s].children=this._group(t+1,a[s].rows);return a},_groupDisplay:function(t,r){for(var e,n=this.s.dt,o=0,i=r.length;o<i;o++){var a,s=r[o],d=s.dataPoint,u=s.rows;this.c.startRender&&(e=this.c.startRender.call(this,n.rows(u),d,t),a=this._rowWrap(e,this.c.startClassName,t))&&a.insertBefore(n.row(u[0]).node()),this.c.endRender&&(e=this.c.endRender.call(this,n.rows(u),d,t),a=this._rowWrap(e,this.c.endClassName,t))&&a.insertAfter(n.row(u[u.length-1]).node()),s.children&&this._groupDisplay(t+1,s.children)}},_rowWrap:function(t,r,e){return null==(t=null!==t&&""!==t?t:this.c.emptyDataGroup)?null:("object"==typeof t&&t.nodeName&&"tr"===t.nodeName.toLowerCase()?i(t):t instanceof i&&t.length&&"tr"===t[0].nodeName.toLowerCase()?t:i("<tr/>").append(i("<th/>").attr("colspan",this._colspan()).attr("scope","row").append(t))).addClass(this.c.className).addClass(r).addClass("dtrg-level-"+e)}}),a.defaults={className:"dtrg-group",dataSrc:0,emptyDataGroup:"No group",enable:!0,endClassName:"dtrg-end",endRender:null,startClassName:"dtrg-start",startRender:function(t,r){return r}},a.version="1.5.0",i.fn.dataTable.RowGroup=a,i.fn.DataTable.RowGroup=a,l.Api.register("rowGroup()",function(){return this}),l.Api.register("rowGroup().disable()",function(){return this.iterator("table",function(t){t.rowGroup&&t.rowGroup.enable(!1)})}),l.Api.register("rowGroup().enable()",function(r){return this.iterator("table",function(t){t.rowGroup&&t.rowGroup.enable(void 0===r||r)})}),l.Api.register("rowGroup().enabled()",function(){var t=this.context;return!(!t.length||!t[0].rowGroup)&&t[0].rowGroup.enabled()}),l.Api.register("rowGroup().dataSrc()",function(r){return void 0===r?this.context[0].rowGroup.dataSrc():this.iterator("table",function(t){t.rowGroup&&t.rowGroup.dataSrc(r)})}),i(r).on("preInit.dt.dtrg",function(t,r,e){var n,o;"dt"===t.namespace&&(t=r.oInit.rowGroup,n=l.defaults.rowGroup,t||n)&&(o=i.extend({},n,t),!1!==t)&&new a(r,o)}),l}); |
@@ -7,3 +7,3 @@ { | ||
"types": "./types/types.d.ts", | ||
"version": "1.4.1", | ||
"version": "1.5.0", | ||
"files": [ | ||
@@ -24,3 +24,3 @@ "js/**/*.js", | ||
"dependencies": { | ||
"datatables.net": ">=1.13.4", | ||
"datatables.net": ">=1.11.0", | ||
"jquery": ">=1.7" | ||
@@ -27,0 +27,0 @@ }, |
@@ -43,3 +43,3 @@ // Type definitions for DataTables RowGroup | ||
*/ | ||
new (dt: Api<any>, settings: boolean | ConfigRowGroup); | ||
new (dt: Api<any>, settings: boolean | ConfigRowGroup): DataTablesStatic['RowGroup']; | ||
@@ -46,0 +46,0 @@ /** |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
906
35942
Updateddatatables.net@>=1.11.0