Skip Menu |

This queue is for tickets about the DBIx-XHTML_Table CPAN distribution.

Report information
The Basics
Id: 5874
Status: rejected
Priority: 0/
Queue: DBIx-XHTML_Table

People
Owner: Nobody in particular
Requestors: brado [...] newtoninst.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.36
Fixed in: (no value)



Subject: totals not correct over 10 columns
DBIx-XHTML_Table-1.36 --------------- no error message, but totals do not appear under the column that they match. Works from 1-9 columns then gets funky above 11 columns. --------------- problem: value returned from _total_chunk is not in same order as original columns. ---------------- fix: add {$a <=> $b} to 'map' line in _total_chunk to force numerical sort of columns. # used by calc_totals() and calc_subtotals() sub _total_chunk { my ($self,$chunk,$indexes) = @_; my %totals; foreach my $row (@$chunk) { foreach (@$indexes) { $totals{$_} += $row->[$_] if $row->[$_] =~ /^[-0-9\.]+$/; } } return [ map { defined $totals{$_} ? $totals{$_} : undef } sort { $a <=> $b} (0..$self->get_col_count() - 1) ]; } ----------------------- This module has been a real timesaver for me. Thank you for the time you have put into it already. Hope this report is useful......
Thanks for the patch. I just now logged in checked up. 6 weeks old. Bad jeffa. :) I will add this to the next version, which may not be out for another month or so. I am also planning to rewrite from the ground up this summer (need landscape as well portrait style display). jeffa [guest - Thu Apr 1 17:00:47 2004]: Show quoted text
> DBIx-XHTML_Table-1.36 > --------------- > no error message, but totals do not appear under the column that they > match. Works from 1-9 columns then gets funky above 11 columns. > --------------- > problem: value returned from _total_chunk is not in same order as > original columns. > ---------------- > fix: > add {$a <=> $b} to 'map' line in _total_chunk to force numerical > sort of columns.
The sort is not even needed, but changing the sort does not impact this bug. Your bug is most likely not a bug, but rather the result of calling calc_totals() without using an array ref, which does indeed mangle the output because your 2nd header is being used as an sprintf mask. Solution, always use an array ref to contain the headers you want to total.