From a33619a4fdf33705b93efab1c9af4cdf5f83734c Mon Sep 17 00:00:00 2001 From: Mottie Date: Fri, 18 Oct 2013 11:19:30 -0500 Subject: [PATCH] Added group_callback & group_complete to grouping widget --- docs/example-widget-grouping.html | 99 ++++++++++++++++++++++++------- docs/index.html | 6 +- js/widgets/widget-grouping.js | 26 ++++++-- 3 files changed, 101 insertions(+), 30 deletions(-) diff --git a/docs/example-widget-grouping.html b/docs/example-widget-grouping.html index 3361378d..da78f207 100644 --- a/docs/example-widget-grouping.html +++ b/docs/example-widget-grouping.html @@ -97,7 +97,22 @@ } // If there are empty cells, name the group "Empty" return txt === "" ? "Empty" : txt; - } + }, + group_callback : function($cell, $rows, column, table){ + // callback allowing modification of the group header labels + // $cell = current table cell (containing group header cells '.group-name' & '.group-count' + // $rows = all of the table rows for the current group; table = current table (DOM) + // column = current column being sorted/grouped + if (column === 2) { + var subtotal = 0; + $rows.each(function(){ + subtotal += parseInt( $(this).find('td').eq(column).text() ); + }); + $cell.find('.group-count').append('; subtotal: ' + subtotal ); + } + }, + // event triggered on the table when the grouping widget has finished work + group_complete : 'groupingComplete' } }); @@ -122,6 +137,7 @@