[Rt-devel] small patch to support multi-column fields in tables
Olly Stephens
Olly.Stephens at arm.com
Sun Oct 26 17:01:08 EDT 2008
Hi,
Below is a small patch against 3.8.1 to the /Elements/CollectionAsTable
components that adds support for a /SPAN:X directive in the formatting
which translates into a colspan="X" element in the table definition.
Works a treat; allows me to have 'Subject' span multiple columns in a
multi-row table definition.
Can't see any immediate reason it would cause problems. Anyone?
Thanks,
Olly
Index: share/html/Elements/CollectionAsTable/ParseFormat
===================================================================
--- share/html/Elements/CollectionAsTable/ParseFormat (revision 6284)
+++ share/html/Elements/CollectionAsTable/ParseFormat (working copy)
@@ -77,6 +77,9 @@
if ( $col =~ s!/ALIGN:([^\/]+)!!io ) {
$colref->{'align'} = $1;
}
+ if ( $col =~ s!/SPAN:([^\/]+)!!io ) {
+ $colref->{'span'} = $1;
+ }
if ( $col =~ /__(.*?)__/io ) {
my @subcols;
while ( $col =~ s/^(.*?)__(.*?)__//o ) {
Index: share/html/Elements/CollectionAsTable/Row
===================================================================
--- share/html/Elements/CollectionAsTable/Row (revision 6284)
+++ share/html/Elements/CollectionAsTable/Row (working copy)
@@ -76,13 +76,15 @@
next;
}
- $item++;
my $class = $column->{class} ? encode_entities( $column->{class},
q{'"&<>} ) : 'collection-as-table';
$m->out(qq{<td class="$class" });
my $align = $column->{align};
my $style = $column->{style};
+ my $span = $column->{span};
+ $item += ($span || 1);
+
my @out;
foreach my $subcol ( @{ $column->{output} } ) {
unless ( $subcol =~ /^__(.*?)__$/ ) {
@@ -131,6 +133,7 @@
}
$m->out( 'align="' . $align . '"' ) if $align;
$m->out( 'style="' . $style . '"' ) if $style;
+ $m->out( 'colspan="' . $span . '"' ) if $span;
$m->out('>');
$m->out(@out) if @out;
$m->out( '</td>' . "\n" );
Index: share/html/Elements/CollectionAsTable/Header
===================================================================
--- share/html/Elements/CollectionAsTable/Header (revision 6284)
+++ share/html/Elements/CollectionAsTable/Header (working copy)
@@ -87,9 +87,12 @@
next;
}
- $item++;
+ my $span = $col->{'span'};
+ $item += ($span || 1);
- $m->out('<th class="collection-as-table">');
+ $m->out('<th class="collection-as-table"');
+ $m->out(' colspan="' . $span . '"') if $span;
+ $m->out('>');
$title =~ s/^__(.*)__$/$1/o;
my $tmp = $m->comp( '/Elements/ColumnMap',
--
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: rt-multicolumn-diff.txt
Url: http://lists.bestpractical.com/pipermail/rt-devel/attachments/20081026/f042dacf/attachment.txt
More information about the Rt-devel
mailing list