Nic Wolff > HTML-DataTable-0.54 > HTML::DataTable

Download:
HTML-DataTable-0.54.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.54   Source  

NAME ^

HTML::DataTable - Print HTML tables from Perl data

VERSION ^

Version 0.54

SYNOPSIS ^

  use HTML::DataTable
  my $list = HTML::DataTable->new(
    data => $cgi_data,
    columns => [
      # hashrefs describing column formats
    ],
    rows => [
      # arrayrefs listing data to show in table
    ],
  );
  print $list;

METHODS ^

new()

Creates a new HTML::DataTable object.

ATTRIBUTES

header_bg

The HTML color code for the background of the first row of the list.

header_bar

If this is defined, there will be a 1px black line under the header.

shade_alternate_rows

If this is defined, then alternating rows will be colored differently.

light_bg, dark_bg

The HTML color codes for the alternating backgrounds of the list rows.

sections

If this evaluates to a reference to a subroutine, then that subroutine will be called with each row's values, and when the returned values changes, the table will be divided and the value printed as a section title. (Since there's no value initially, there will be a section title before the first row.)

section_headers

If this is defined, the table header will be reprinted after each section title.

alphabet

If this is defined, a linked alphabet index will be printed above the table header. Subclasses of this class are responsible for using the "letter" CGI parameter to show the appropriate rows.

search

If this is defined, then a field called "search" will be shown in the table header (after the alphabet, if that attribute is also defined). If it evaluates to a reference to a hash, then the keys of the hash will be shown in a SELECT control called "search_columns" after the field. Subclasses of this class are responsible for using these CGI parameters to show the appropriate rows.

data

Should be assigned a hashref representing the CGI parameters.

rows

One of:

* An arrayref listing one arrayref holding the values to appear in each row of the list.

* An arrayref listing one hashref holding the values to appear in each row of the list.

* A hashref mapping each row's ID to a hashref holding the values to appear in that row of the list, in which case the "sort" attribute should name the hash key by which to sort the hashref entries.

columns

An arrayref listing one hashref defining each column of the table. These hashrefs can have these attributes:

header

The text to print at the top of this column.

category

A second-level header to be printed above the column header; adjacent column's category headers will be merged if they are the same.

format

This can be either

* A scalar, which will be used as an index in the current row's data array

* An arrayref, which will list an index in the current row's data array and singular and plural nouns to append to the value found there

* A reference to a subroutine, which will be passed the current row's data array

* A hashref, which will map a predefined format name to an index in the current row's data array

none

A string to show if the value in that column is undefined. Defaults to "None".

style, class, align

If any of these attributes evaluate to a string, they will become the corresponding attributes of each table cell in the column.

action

The path or URL of a CGI program to which each entry will linked.

data

A reference to a hash listing the CGI parameters to be included in the "action" link. Each value is either a scalar or a reference, as for the "format" attribute.

link_empty

If defined, then if the value in the column is undefined the "None" shown will be linked to the "action" URL.

norepeat

If this is defined, then the column will be left blank if the value printed would be the same the that for the previous row.

nobr

If this is defined, then the column's content will be surrounded by <nobr> tags so it isn't formatted into multiple lines.

list_HTML()

Returns the HTML that renders the list.

xls

Returns the list as an Excel spreadsheet.

SEE ALSO ^

HTML::DataTable::DBI, HTML::FromArrayref

AUTHORS ^

Nic Wolff <nic@angel.net> Jason Barden <jason@angel.net>

syntax highlighting: