Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

datatables.net-rowgroup

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datatables.net-rowgroup - npm Package Compare versions

Comparing version 1.3.1 to 1.4.0

269

js/dataTables.rowGroup.js

@@ -1,2 +0,2 @@

/*! RowGroup 1.3.1
/*! RowGroup 1.4.0
* © SpryMedia Ltd - datatables.net/license

@@ -21,3 +21,3 @@ */

if (typeof window !== 'undefined') {
if (typeof window === 'undefined') {
module.exports = function (root, $) {

@@ -56,3 +56,3 @@ if ( ! root ) {

* @description RowGrouping for DataTables
* @version 1.3.1
* @version 1.4.0
* @author SpryMedia Ltd (www.sprymedia.co.uk)

@@ -72,5 +72,5 @@ * @contact datatables.net

var RowGroup = function ( dt, opts ) {
var RowGroup = function (dt, opts) {
// Sanity check that we are using DataTables 1.10 or newer
if ( ! DataTable.versionCheck || ! DataTable.versionCheck( '1.10.8' ) ) {
if (!DataTable.versionCheck || !DataTable.versionCheck('1.10.8')) {
throw 'RowGroup requires DataTables 1.10.8 or newer';

@@ -80,22 +80,16 @@ }

// User and defaults configuration object
this.c = $.extend( true, {},
DataTable.defaults.rowGroup,
RowGroup.defaults,
opts
);
this.c = $.extend(true, {}, DataTable.defaults.rowGroup, RowGroup.defaults, opts);
// Internal settings
this.s = {
dt: new DataTable.Api( dt )
dt: new DataTable.Api(dt)
};
// DOM items
this.dom = {
this.dom = {};
};
// Check if row grouping has already been initialised on this table
var settings = this.s.dt.settings()[0];
var existing = settings.rowGroup;
if ( existing ) {
if (existing) {
return existing;

@@ -108,4 +102,3 @@ }

$.extend( RowGroup.prototype, {
$.extend(RowGroup.prototype, {
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

@@ -120,5 +113,4 @@ * API methods for DataTables API interface

*/
dataSrc: function ( val )
{
if ( val === undefined ) {
dataSrc: function (val) {
if (val === undefined) {
return this.c.dataSrc;

@@ -131,3 +123,3 @@ }

$(dt.table().node()).triggerHandler( 'rowgroup-datasrc.dt', [ dt, val ] );
$(dt.table().node()).triggerHandler('rowgroup-datasrc.dt', [dt, val]);

@@ -141,4 +133,3 @@ return this;

*/
disable: function ()
{
disable: function () {
this.c.enable = false;

@@ -152,5 +143,4 @@ return this;

*/
enable: function ( flag )
{
if ( flag === false ) {
enable: function (flag) {
if (flag === false) {
return this.disable();

@@ -167,13 +157,10 @@ }

*/
enabled: function ()
{
enabled: function () {
return this.c.enable;
},
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Constructor
*/
_constructor: function ()
{
_constructor: function () {
var that = this;

@@ -183,18 +170,17 @@ var dt = this.s.dt;

dt.on( 'draw.dtrg', function (e, s) {
if ( that.c.enable && hostSettings === s ) {
dt.on('draw.dtrg', function (e, s) {
if (that.c.enable && hostSettings === s) {
that._draw();
}
} );
});
dt.on( 'column-visibility.dt.dtrg responsive-resize.dt.dtrg', function () {
dt.on('column-visibility.dt.dtrg responsive-resize.dt.dtrg', function () {
that._adjustColspan();
} );
});
dt.on( 'destroy', function () {
dt.off( '.dtrg' );
} );
dt.on('destroy', function () {
dt.off('.dtrg');
});
},
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

@@ -208,6 +194,6 @@ * Private methods

*/
_adjustColspan: function ()
{
$( 'tr.'+this.c.className, this.s.dt.table().body() ).find('td:visible')
.attr( 'colspan', this._colspan() );
_adjustColspan: function () {
$('tr.' + this.c.className, this.s.dt.table().body())
.find('td:visible')
.attr('colspan', this._colspan());
},

@@ -219,10 +205,11 @@

*/
_colspan: function ()
{
return this.s.dt.columns().visible().reduce( function (a, b) {
return a + b;
}, 0 );
_colspan: function () {
return this.s.dt
.columns()
.visible()
.reduce(function (a, b) {
return a + b;
}, 0);
},
/**

@@ -234,8 +221,7 @@ * Update function that is called whenever we need to draw the grouping rows.

*/
_draw: function ()
{
_draw: function () {
var dt = this.s.dt;
var groupedRows = this._group( 0, dt.rows( { page: 'current' } ).indexes() );
var groupedRows = this._group(0, dt.rows({ page: 'current' }).indexes());
this._groupDisplay( 0, groupedRows );
this._groupDisplay(0, groupedRows);
},

@@ -262,5 +248,5 @@

*/
_group: function ( level, rows ) {
var fns = Array.isArray( this.c.dataSrc ) ? this.c.dataSrc : [ this.c.dataSrc ];
var fn = DataTable.ext.oApi._fnGetObjectDataFn( fns[ level ] );
_group: function (level, rows) {
var fns = Array.isArray(this.c.dataSrc) ? this.c.dataSrc : [this.c.dataSrc];
var fn = DataTable.ext.oApi._fnGetObjectDataFn(fns[level]);
var dt = this.s.dt;

@@ -271,16 +257,16 @@ var group, last;

for ( var i=0, ien=rows.length ; i<ien ; i++ ) {
for (var i = 0, ien = rows.length; i < ien; i++) {
var rowIndex = rows[i];
var rowData = dt.row( rowIndex ).data();
var group = fn( rowData );
var rowData = dt.row(rowIndex).data();
var group = fn(rowData);
if ( group === null || group === undefined ) {
if (group === null || group === undefined) {
group = that.c.emptyDataGroup;
}
if ( last === undefined || group !== last ) {
data.push( {
if (last === undefined || group !== last) {
data.push({
dataPoint: group,
rows: []
} );
});

@@ -290,8 +276,8 @@ last = group;

data[ data.length-1 ].rows.push( rowIndex );
data[data.length - 1].rows.push(rowIndex);
}
if ( fns[ level+1 ] !== undefined ) {
for ( var i=0, ien=data.length ; i<ien ; i++ ) {
data[i].children = this._group( level+1, data[i].rows );
if (fns[level + 1] !== undefined) {
for (var i = 0, ien = data.length; i < ien; i++) {
data[i].children = this._group(level + 1, data[i].rows);
}

@@ -309,8 +295,7 @@ }

*/
_groupDisplay: function ( level, groups )
{
_groupDisplay: function (level, groups) {
var dt = this.s.dt;
var display;
for ( var i=0, ien=groups.length ; i<ien ; i++ ) {
for (var i = 0, ien = groups.length; i < ien; i++) {
var group = groups[i];

@@ -321,22 +306,22 @@ var groupName = group.dataPoint;

if ( this.c.startRender ) {
display = this.c.startRender.call( this, dt.rows(rows), groupName, level );
row = this._rowWrap( display, this.c.startClassName, level );
if (this.c.startRender) {
display = this.c.startRender.call(this, dt.rows(rows), groupName, level);
row = this._rowWrap(display, this.c.startClassName, level);
if ( row ) {
row.insertBefore( dt.row( rows[0] ).node() );
if (row) {
row.insertBefore(dt.row(rows[0]).node());
}
}
if ( this.c.endRender ) {
display = this.c.endRender.call( this, dt.rows(rows), groupName, level );
row = this._rowWrap( display, this.c.endClassName, level );
if (this.c.endRender) {
display = this.c.endRender.call(this, dt.rows(rows), groupName, level);
row = this._rowWrap(display, this.c.endClassName, level);
if ( row ) {
row.insertAfter( dt.row( rows[ rows.length-1 ] ).node() );
if (row) {
row.insertAfter(dt.row(rows[rows.length - 1]).node());
}
}
if ( group.children ) {
this._groupDisplay( level+1, group.children );
if (group.children) {
this._groupDisplay(level + 1, group.children);
}

@@ -355,38 +340,40 @@ }

*/
_rowWrap: function ( display, className, level )
{
_rowWrap: function (display, className, level) {
var row;
if ( display === null || display === '' ) {
if (display === null || display === '') {
display = this.c.emptyDataGroup;
}
if ( display === undefined || display === null ) {
if (display === undefined || display === null) {
return null;
}
if ( typeof display === 'object' && display.nodeName && display.nodeName.toLowerCase() === 'tr') {
if (
typeof display === 'object' &&
display.nodeName &&
display.nodeName.toLowerCase() === 'tr'
) {
row = $(display);
}
else if (display instanceof $ && display.length && display[0].nodeName.toLowerCase() === 'tr') {
else if (
display instanceof $ &&
display.length &&
display[0].nodeName.toLowerCase() === 'tr'
) {
row = display;
}
else {
row = $('<tr/>')
.append(
$('<th/>')
.attr( 'colspan', this._colspan() )
.attr( 'scope', 'row' )
.append( display )
);
row = $('<tr/>').append(
$('<th/>').attr('colspan', this._colspan()).attr('scope', 'row').append(display)
);
}
return row
.addClass( this.c.className )
.addClass( className )
.addClass( 'dtrg-level-'+level );
.addClass(this.c.className)
.addClass(className)
.addClass('dtrg-level-' + level);
}
} );
});
/**

@@ -447,3 +434,3 @@ * RowGroup default settings for initialisation

*/
startRender: function ( rows, group ) {
startRender: function (rows, group) {
return group;

@@ -453,55 +440,49 @@ }

RowGroup.version = '1.4.0';
RowGroup.version = "1.3.1";
$.fn.dataTable.RowGroup = RowGroup;
$.fn.DataTable.RowGroup = RowGroup;
DataTable.Api.register( 'rowGroup()', function () {
DataTable.Api.register('rowGroup()', function () {
return this;
} );
});
DataTable.Api.register( 'rowGroup().disable()', function () {
return this.iterator( 'table', function (ctx) {
if ( ctx.rowGroup ) {
ctx.rowGroup.enable( false );
DataTable.Api.register('rowGroup().disable()', function () {
return this.iterator('table', function (ctx) {
if (ctx.rowGroup) {
ctx.rowGroup.enable(false);
}
} );
} );
});
});
DataTable.Api.register( 'rowGroup().enable()', function ( opts ) {
return this.iterator( 'table', function (ctx) {
if ( ctx.rowGroup ) {
ctx.rowGroup.enable( opts === undefined ? true : opts );
DataTable.Api.register('rowGroup().enable()', function (opts) {
return this.iterator('table', function (ctx) {
if (ctx.rowGroup) {
ctx.rowGroup.enable(opts === undefined ? true : opts);
}
} );
} );
});
});
DataTable.Api.register( 'rowGroup().enabled()', function () {
DataTable.Api.register('rowGroup().enabled()', function () {
var ctx = this.context;
return ctx.length && ctx[0].rowGroup ?
ctx[0].rowGroup.enabled() :
false;
} );
return ctx.length && ctx[0].rowGroup ? ctx[0].rowGroup.enabled() : false;
});
DataTable.Api.register( 'rowGroup().dataSrc()', function ( val ) {
if ( val === undefined ) {
DataTable.Api.register('rowGroup().dataSrc()', function (val) {
if (val === undefined) {
return this.context[0].rowGroup.dataSrc();
}
return this.iterator( 'table', function (ctx) {
if ( ctx.rowGroup ) {
ctx.rowGroup.dataSrc( val );
return this.iterator('table', function (ctx) {
if (ctx.rowGroup) {
ctx.rowGroup.dataSrc(val);
}
} );
} );
});
});
// Attach a listener to the document which listens for DataTables initialisation
// events so we can automatically initialise
$(document).on( 'preInit.dt.dtrg', function (e, settings, json) {
if ( e.namespace !== 'dt' ) {
$(document).on('preInit.dt.dtrg', function (e, settings, json) {
if (e.namespace !== 'dt') {
return;

@@ -513,10 +494,10 @@ }

if ( init || defaults ) {
var opts = $.extend( {}, defaults, init );
if (init || defaults) {
var opts = $.extend({}, defaults, init);
if ( init !== false ) {
new RowGroup( settings, opts );
if (init !== false) {
new RowGroup(settings, opts);
}
}
} );
});

@@ -523,0 +504,0 @@

@@ -1,4 +0,4 @@

/*! RowGroup 1.3.1
/*! RowGroup 1.4.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("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.3.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(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("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.0",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});

@@ -7,3 +7,3 @@ {

"types": "./types/types.d.ts",
"version": "1.3.1",
"version": "1.4.0",
"files": [

@@ -24,3 +24,3 @@ "js/**/*.js",

"dependencies": {
"datatables.net": ">=1.12.1",
"datatables.net": ">=1.13.4",
"jquery": ">=1.7"

@@ -27,0 +27,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc