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

I know, unfortunately I didn't provide code. The structure makes rounding up the pertinent parts difficult, but I'll give it a try.

Here is where I gather the values and insert the array reference:

my $noteshandler = $dbh->prepare($notessql); $noteshandler->execute($id, $version); while ( my @note = $noteshandler->fetchrow_arrayref() ) { push ( @noteslist, $note[0]); } $attrHashListRef->[$index]->{VALUE} = \@noteslist;

Here is where I put my tables together:

###begin OUTER Table containing part list and selected part info $data .= $cgi->start_table({}); ###begin row in OUTER table. $data .= $cgi->start_Tr({}); ###Left most cell in OUTER table. Contains PartList. $data .= $cgi->td({-valign=>'top'}, renderPartListView($cgi)); ###begin Right cell in OUTER table. Contains Header and selected ###part info. $data .= $cgi->start_td({-valign=>'top' }); ###begin INNER table containing header and view $data .= $cgi->start_table({}); ###Top ROW on INNER table. Containing header $data .= $cgi->Tr({}, $cgi->td({}, pageHeader($cgi, $lca_dbm, $am))); ###begin bottom ROW on INNER table. Containing selected part $data .= $cgi->start_Tr({-width => 20, -style => 'white-space:wrap +'}); $data .= $cgi->td({-valign=>'top'}, renderPartReadView($cgi, $lca_dbm, $am) ###end bottom ROW on INNER table. Containing selected part $data .= $cgi->end_Tr({}); ###end INNER table containing header and view $data .= $cgi->end_table(); ###end Right cell in OUTER table. $data .= $cgi->end_td({}); ###end row in OUTER table. $data .= $cgi->end_Tr(); ###end OUTER Table containing part list and selected part info $data .= $cgi->end_table(); $logger->info("Exiting renderView"); return $data;

Like I said, not pretty.

Replies are listed 'Best First'.
Re^3: CGI table problems
by cLive ;-) (Prior) on Nov 09, 2006 at 18:58 UTC
    Template it. That's a mess and will be even worse to maintain.
Re^3: CGI table problems
by pKai (Priest) on Nov 10, 2006 at 10:54 UTC
    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)} )
      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)} );