Skip to content

Commit

Permalink
Grouping widget collapsed option shows headers. Fixes #514
Browse files Browse the repository at this point in the history
  • Loading branch information
Mottie committed Feb 25, 2014
1 parent cf1ea13 commit 5b38501
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/example-widget-grouping.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
if (column === 2) {
var subtotal = 0;
$rows.each(function(){
subtotal += parseInt( $(this).find("td").eq(column).text() );
subtotal += parseFloat( $(this).find("td").eq(column).text() );
});
$cell.find(".group-count").append("; subtotal: " + subtotal );
}
Expand Down
25 changes: 13 additions & 12 deletions js/widgets/widget-grouping.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ ts.grouping = {
cache = c.cache[tbodyIndex].normalized;
group = ''; // clear grouping across tbodies
$rows = c.$tbodies.eq(tbodyIndex).children('tr').not('.' + c.cssChildRow);
if (wo.group_collapsed && wo.group_collapsible) {
$rows.addClass('group-hidden');
}
for (rowIndex = 0; rowIndex < $rows.length; rowIndex++) {
if ( $rows.eq(rowIndex).is(':visible') ) {
// group class finds "group-{word/separator/letter/number/date/false}-{optional:#/year/month/day/week/time}"
Expand Down Expand Up @@ -103,23 +100,27 @@ ts.grouping = {
}
}
}
$rows = c.$table.find('tr.group-header').bind('selectstart', false);
if (wo.group_count || $.isFunction(wo.group_callback)) {
$rows.each(function(){
var $rows,
$row = $(this),
$label = $row.find('.group-count');
c.$table.find('tr.group-header')
.bind('selectstart', false)
.each(function(){
var $label,
$row = $(this),
$rows = $row.nextUntil('tr.group-header').filter(':visible');
if (wo.group_count || $.isFunction(wo.group_callback)) {
$label = $row.find('.group-count');
if ($label.length) {
$rows = $row.nextUntil('tr.group-header').filter(':visible');
if (wo.group_count) {
$label.html( wo.group_count.replace(/\{num\}/g, $rows.length) );
}
if ($.isFunction(wo.group_callback)) {
wo.group_callback($row.find('td'), $rows, column, table);
}
}
});
}
}
if (wo.group_collapsed && wo.group_collapsible) {
$rows.addClass('group-hidden');
}
});
c.$table.trigger(wo.group_complete);
if (c.debug) {
$.tablesorter.benchmark("Applying groups widget: ", time);
Expand Down

0 comments on commit 5b38501

Please sign in to comment.