NAME
CGI::List - Easily generate HTML Lists From a DataBase
VERSION
Version 0.01
SYNOPSIS
Easily create html lists whit auto order, auto pagination, grouping and conditional formats.
Perhaps a little code snippet.
use CGI::List;
#We need a DBH Handle
$dbh = DBI->connect(.....);
#Create List Object
$list = CGI::List->new(
dbh => $dbh,
sql => "SELECT * FROM foot",
);
#Print
print $list->print();
FEATURES
* CSS based. Contact developer for CSS examples
* Column totals(Only SUM, COUNT and AVG are supported)
* Conditional formats for rows
* Conditional Formats for cells
* Auto detect column names
* Auto Order
* Auto Pagination
* 2 row formats for better visualization
* Row grouping
* Http Link and highlight on rows based in rows keys
* Opener action for pop up windows
METHODS
new()
This method creates a new $list object, which you then use to generate and process your list.
my $list = CGI::List->new(dbh=>$dbh,
sql => "SELECT * FROM foot");
The following is a description of each option, in alphabetical order:
name => 'list_name'
If you use a multi lists pages you need to specify a name for each list
caption => 'list title'
This create a list title with the caption html tag
auto_order => 1 | 0, default 1
Enable, disable auto order mechanism on the list
pagination => 1 | 0, default 1
Enable or disable auto pagination on the list
nav_pages => $number, default 4
Number of pages you can see on pagination
print()
This function renders the grid into HTML, and returns a string containing the grid.
print $list->print;
group()
This method Create groups of data:
$list->group(key=>'key_field',fields=>[qw/key_field other_field other_field/]);
group_total()
This method calculate row totals on each group:
$list->total(key=>'key_field',type=>"MATH",operation=>'SUM',label=>"%% some text");
Operation support only SUM, AVG, and COUNT
total()
This method calculate row totals:
$list->total(key=>'key_field',type=>"MATH",operation=>'SUM',label=>"%% some text");
Operation suport only SUM, AVG, and COUNT
row_format()
This function specify a format of row depending on their value
$list->row_format(name=>"field_name",condition=>"'%%' eq 'urgent'",params=>{class=>"cl_row_urgent"});
%% is the cell value, on this example you need to create 2 css class cl_row_urgent and cl_row_urgent_hover for the hover action
cell_format();
This function specify a format of cell depending on their value
$list->cell_format(name=>"field_name",condition=>"'%%' eq 'urgent'",params=>{class=>"cl_cell_urgent"});
%% is the cell value, on this example you need to create 2 css class cl_cell_urgent and cl_cell_urgent_hover for the hover action
columns_width()
This function specify the width of each column
$list->columns_width(["100","200","300"]);
On this example you have a 3 columns query and 100, 200, 300 are the width of each column
columns_align()
This function specify the horizontal align of each column
$list->columns_align(["left","center","right"]);
On this example you have a 3 columns query and left, center, right are the alignment of each column data
columns_headers_align()
This function specify the horizontal align of each column header
$list->columns_headers_align(["left","center","right"]);
On this example you have a 3 columns query and left, center, right are the alignment of each column header data
Examples
This example provides an list of data with auto order, auto pagination and action on each row click
my $list = CGI::Grid->new(
dbh => $dbh,
name => "pays_list",
sql => {
select => "p.pay_id, p.date, pr.name, " .
"IF(p.is_cancel,'Cancel','Active') AS 'status'",
from => "pays p INNER JOIN partners pr ON p.pay_id=pr.pay_id ",
limit => "20",
where => "some_column=? AND some_column=?",
params=>["Value1","Value2"],
order_by => "p.date DESC",
},
link => {
key => "pay_id",
hidde_key_col => 1,
location => "pays.pl",
transit_params => {some_param_to_be_present_everywere=>"value"},
},
);
$list->print();
AUTHOR
David Romero García, <romdav at gmail.com>
BUGS
Please report any bugs or feature requests to bug-cgi-list at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CGI-List. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc CGI::List
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
RT: CPAN's request tracker
Search CPAN
ACKNOWLEDGEMENTS
COPYRIGHT & LICENSE
Copyright 2007 David Romero García, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 1014:
Non-ASCII character seen before =encoding in 'García,'. Assuming UTF-8