Grouping widget collapsed option shows headers. Fixes #514

This commit is contained in:
Mottie 2014-02-25 09:34:03 -06:00
parent cf1ea135cb
commit 5b38501408
2 changed files with 14 additions and 13 deletions

View File

@ -108,7 +108,7 @@ tr.group-header.collapsed td i {
if (column === 2) { if (column === 2) {
var subtotal = 0; var subtotal = 0;
$rows.each(function(){ $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 ); $cell.find(".group-count").append("; subtotal: " + subtotal );
} }

View File

@ -70,9 +70,6 @@ ts.grouping = {
cache = c.cache[tbodyIndex].normalized; cache = c.cache[tbodyIndex].normalized;
group = ''; // clear grouping across tbodies group = ''; // clear grouping across tbodies
$rows = c.$tbodies.eq(tbodyIndex).children('tr').not('.' + c.cssChildRow); $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++) { for (rowIndex = 0; rowIndex < $rows.length; rowIndex++) {
if ( $rows.eq(rowIndex).is(':visible') ) { if ( $rows.eq(rowIndex).is(':visible') ) {
// group class finds "group-{word/separator/letter/number/date/false}-{optional:#/year/month/day/week/time}" // group class finds "group-{word/separator/letter/number/date/false}-{optional:#/year/month/day/week/time}"
@ -103,14 +100,15 @@ ts.grouping = {
} }
} }
} }
$rows = c.$table.find('tr.group-header').bind('selectstart', false); c.$table.find('tr.group-header')
if (wo.group_count || $.isFunction(wo.group_callback)) { .bind('selectstart', false)
$rows.each(function(){ .each(function(){
var $rows, var $label,
$row = $(this), $row = $(this),
$label = $row.find('.group-count'); $rows = $row.nextUntil('tr.group-header').filter(':visible');
if (wo.group_count || $.isFunction(wo.group_callback)) {
$label = $row.find('.group-count');
if ($label.length) { if ($label.length) {
$rows = $row.nextUntil('tr.group-header').filter(':visible');
if (wo.group_count) { if (wo.group_count) {
$label.html( wo.group_count.replace(/\{num\}/g, $rows.length) ); $label.html( wo.group_count.replace(/\{num\}/g, $rows.length) );
} }
@ -118,8 +116,11 @@ ts.grouping = {
wo.group_callback($row.find('td'), $rows, column, table); 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); c.$table.trigger(wo.group_complete);
if (c.debug) { if (c.debug) {
$.tablesorter.benchmark("Applying groups widget: ", time); $.tablesorter.benchmark("Applying groups widget: ", time);