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.0.2 to 1.0.3

170

js/dataTables.rowGroup.js

@@ -1,3 +0,3 @@

/*! RowGroup 1.0.2
* ©2017 SpryMedia Ltd - datatables.net/license
/*! RowGroup 1.0.3
* ©2017-2018 SpryMedia Ltd - datatables.net/license
*/

@@ -8,7 +8,7 @@

* @description RowGrouping for DataTables
* @version 1.0.2
* @version 1.0.3
* @file dataTables.rowGroup.js
* @author SpryMedia Ltd (www.sprymedia.co.uk)
* @contact datatables.net
* @copyright Copyright 2017 SpryMedia Ltd.
* @copyright Copyright 2017-2018 SpryMedia Ltd.
*

@@ -72,5 +72,10 @@ * This source file is free software, available under the following license:

dataFn: DataTable.ext.oApi._fnGetObjectDataFn( this.c.dataSrc )
dataFn: []
};
for (let i = 0; i < this.c.dataSrc.length; i++) {
this.s.dataFn.push(DataTable.ext.oApi._fnGetObjectDataFn( this.c.dataSrc[i] ))
}
// DOM items

@@ -151,3 +156,14 @@ this.dom = {

var dt = this.s.dt;
var rows = dt.rows();
var groups = [];
rows.every( function () {
var d = this.data();
var group = that.s.dataFn( d );
if ( groups.indexOf(group) == -1 ) {
groups.push( group );
}
} );
dt.on( 'draw.dtrg', function () {

@@ -166,2 +182,6 @@ if ( that.c.enable ) {

} );
dt.on('responsive-resize.dt', function () {
that._adjustColspan();
})
},

@@ -180,3 +200,3 @@

{
$( 'tr.'+this.c.className, this.s.dt.table().body() )
$( 'tr.'+this.c.className, this.s.dt.table().body() ).find('td')
.attr( 'colspan', this._colspan() );

@@ -202,39 +222,52 @@ },

{
var that = this;
var dt = this.s.dt;
var rows = dt.rows( { page: 'current' } );
var groupedRows = [];
var last, display;
var dataFn = this.s.dataFn
for(let j = 0; j < dataFn.length; j++)
{
var dt = this.s.dt;
var rows = dt.rows( { page: 'current' } );
var groupedRows = [];
var last, lastGroupBefore, display;
rows.every( function () {
var d = this.data();
var group = that.s.dataFn( d );
rows.every( function () {
var d = this.data();
var group = dataFn[j]( d );
var groupBefore = j > 0 ? dataFn[j - 1]( d ) : undefined;
if ( last === undefined || group !== last ) {
groupedRows.push( [] );
last = group;
}
groupedRows[ groupedRows.length - 1 ].push( this.index() );
} );
if ( last === undefined || group !== last ||
(groupBefore !== undefined && lastGroupBefore === undefined) ||
(groupBefore !== undefined && groupBefore !== lastGroupBefore) ) {
groupedRows.push( [] );
last = group;
groupBefore !== undefined ? lastGroupBefore = groupBefore : lastGroupBefore = undefined
}
groupedRows[ groupedRows.length - 1 ].push( this.index() );
} );
for ( var i=0, ien=groupedRows.length ; i<ien ; i++ ) {
var group = groupedRows[i];
var firstRow = dt.row(group[0]);
var groupName = this.s.dataFn( firstRow.data() );
for ( var i=0, ien=groupedRows.length ; i<ien ; i++ ) {
var group = groupedRows[i];
var firstRow = dt.row(group[0]);
var groupName = dataFn[j]( firstRow.data() );
var gpm = this.s.dt.columns().header()[this.c.dataSrc[j]].innerText.capitalize()
if ( this.c.startRender ) {
display = this.c.startRender.call( this, dt.rows(group), groupName );
groupName = gpm ? gpm + ': ' + groupName : groupName
let gpNM = j === 0 ? this.c.startClassName + '-' + j : 'subgroup-' + j
this
._rowWrap( display, this.c.startClassName )
.insertBefore( firstRow.node() );
}
if ( this.c.startRender ) {
display = this.c.startRender.call( this, dt.rows(group), groupName );
if ( this.c.endRender ) {
display = this.c.endRender.call( this, dt.rows(group), groupName );
this
._rowWrap( display, this.c.endClassName )
.insertAfter( dt.row( group[ group.length-1 ] ).node() );
this
._rowWrap( display, gpNM, group, j )
.insertBefore( firstRow.node() );
}
if ( this.c.endRender ) {
display = this.c.endRender.call( this, dt.rows(group), groupName );
this
._rowWrap( display, this.c.endClassName, group, j )
.insertAfter( dt.row( group[ group.length-1 ] ).node() );
}
}

@@ -249,8 +282,18 @@ }

* @param [string] className Class to add to the row
* @param [array] group
* @param [number] group level
* @private
*/
_rowWrap: function ( display, className )
_rowWrap: function ( display, className, group, level )
{
var row;
if ( display === null || display === undefined || display === '' ) {
display = this.c.emptyDataGroup;
}
if ( display === null ) {
return null;
}
if ( typeof display === 'object' && display.nodeName && display.nodeName.toLowerCase() === 'tr') {

@@ -271,5 +314,42 @@ row = $(display);

return row
.addClass( this.c.className )
.addClass( className );
let dt = this.s.dt
row.addClass( this.c.className )
.addClass( className )
.css('cursor', 'pointer')
$(row).on('click', function() {
let currentRow = $(this).next()
let hide = true
if($(this).data('colapsed')) {
$(this).data('colapsed', false)
hide = false
}
else {
$(this).data('colapsed', true)
hide = true
}
// Verifica se é um grupo root
let isRootGroup = $(this).attr("class").split(' ').map((item) => { return item.indexOf('group-start-') !== -1 }).indexOf(true) !== -1;
if(isRootGroup) {
// Percorre todas as linhas até encontrar o proximo grupo root
while ($(currentRow).attr("class") && !($(currentRow).attr("class").split(' ').map((item) => { return item.indexOf('group-start-') !== -1 }).indexOf(true) !== -1)) {
hide ? $(currentRow).hide(400) : $(currentRow).show(400)
currentRow = $(currentRow).next()
}
}
else { // Se for um subgrupo
// Percorre ate encontrar o proximo subgrupo
while ($(currentRow).attr("class") && !($(currentRow).attr("class").split(' ').map((item) => { return item.indexOf('subgroup') !== -1 }).indexOf(true) !== -1) &&
!($(currentRow).attr("class").split(' ').map((item) => { return item.indexOf('group-start-') !== -1 }).indexOf(true) !== -1)) {
hide ? $(currentRow).hide(400) : $(currentRow).show(400)
currentRow = $(currentRow).next()
}
}
})
return row;
}

@@ -301,2 +381,8 @@ } );

/**
* Text to show if no data is found for a group
* @type string
*/
emptyDataGroup: 'No group',
/**
* Initial enablement state

@@ -335,3 +421,3 @@ * @boolean

RowGroup.version = "1.0.2";
RowGroup.version = "1.0.3";

@@ -338,0 +424,0 @@

{
"name": "datatables.net-rowgroup",
"version": "1.0.2",
"version": "1.0.3",
"description": "RowGroup for DataTables ",

@@ -8,3 +8,3 @@ "files": [

],
"main": "./js/dataTables.rowGroup.js",
"main": "js/dataTables.rowGroup.js",
"keywords": [

@@ -11,0 +11,0 @@ "row grouping",

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