in reply to Re^2: CGI table problems
in thread CGI table problems

Fixing a syntax error (missing ");" in the renderPartReadView line, substituting the embedded sub calls by their string representation, I got a table like

renderPartListView($cgi)
pageHeader($cgi, $lca_dbm, $am)
renderPartReadView($cgi, $lca_dbm, $am)

I'm still not sure where your problem resides. Assuming for now that renderPartListView returns an arrayref, and rather then seeing something like this:

part1 part2 part3
pageHeader($cgi, $lca_dbm, $am)
renderPartReadView($cgi, $lca_dbm, $am)

you would more like this:

part0
pageHeader($cgi, $lca_dbm, $am)
renderPartReadView($cgi, $lca_dbm, $am)
part1
part2

???

Well, it can be done… but is likely to obscure your programm even further.

"Easiest" way I see (in the sense that you only make 1 local change) is introducing another table [:-/] for the left part, as in:

part1
part2
part3
pageHeader($cgi, $lca_dbm, $am)
renderPartReadView($cgi, $lca_dbm, $am)

To achieve that, replace the call to renderPartListView with the following:

$cgi->table( map{ $cgi->Tr($cgi->td($_) ) } @{renderPartListView($cgi)} )

Replies are listed 'Best First'.
Re^4: CGI table problems
by rashley (Scribe) on Nov 10, 2006 at 13:49 UTC
    Actually, the problem is within renderPartReadView.

    It creates a verticle list of label/value pairs, which is fine.

    The problem is when the value is a list, it puts the values side by side, and I want them stacked.

      I see no problem for the same argument to apply (replace the td-content with a table of rows of one td each):
      $data .= $cgi->td({-valign=>'top'}, $cgi->table( map{ $cgi->Tr($cgi->td($_) ) } @{render +PartReadView($cgi, $lca_dbm, $am)} );
        I finally got this to work just the way I wanted. I checked the result to see if it was an array ref, then formed a sub-table if it was:
        #massage multi-values for formatting if ( ref $encodedvalue eq 'ARRAY' ) { my $listtable .= $cgi->start_table({-border=>0}); for ( my $i=0; $i<scalar( @$encodedvalue) ; $i++ ) { $listtable .= $cgi->Tr({}, $cgi->th(@$encodedvalue[$i]) ); } $listtable .= $cgi->end_table(); $data .= Tr({}, $cgi->td({-class=>'label'}, $attrHash->{ATTRNAME}), $cgi->td({-class=>'value'}, ($listtable || $cgi->p('&nbsp;')))); } else { $data .= Tr({}, $cgi->td({-class=>'label'}, $attrHash->{ATTRNAME}), $cgi->td({-class=>'value'}, ($encodedvalue || $cgi->p('&nbsp;')))); }}