Class::DBI::Plugin::FilterOnClick

Class::DBI::Plugin::FilterOnClick is a Perl module to generate browsable and searchable HTML Tables.
Download

Class::DBI::Plugin::FilterOnClick Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Aaron Johnson
  • Publisher web site:
  • http://search.cpan.org/~aaronjj/Class-DBI-Plugin-FilterOnClick-1.0/FilterOnClick.pm

Class::DBI::Plugin::FilterOnClick Tags


Class::DBI::Plugin::FilterOnClick Description

Class::DBI::Plugin::FilterOnClick is a Perl module to generate browsable and searchable HTML Tables. Class::DBI::Plugin::FilterOnClick is a Perl module to generate browsable and searchable HTML Tables using FilterOnClick in conjunction with Class::DBI.SYNOPSIS # Inside of your sub-class of Class::DBI add these lines: use Class::DBI::Plugin::FilterOnClick; use Class::DBI::Pager; use Class::DBI::AbstractSearch; use Class::DBI::Plugin::AbstractCount; use Class::DBI::Plugin::RetrieveAll; ..... # Inside your script you will be able to use this modules # methods on your table class or object as needed. use ClassDBIBaseClass; use URI::Escape; use CGI; my $cgi = CGI->new(); my %params; map { $params{$_} = uri_unescape($cgi->param("$_")) } $cgi->param(); my $filteronclick = Baseball::Master->filteronclick( -config_file => '/srv/www/cgi-bin/baseball.ini', # -rows => $cgi->param('rows') || 15 , -on_page => $cgi->param('page') || 1, -params => %params ); $filteronclick->field_to_column( lastname => 'Last Name' . $html->order_by_link('lastname'), firstname => 'First Name' . $html->order_by_link('firstname'), bats => 'Bats', throws => 'Throws', ht_ft => 'Height Ft', ht_in => 'In', wt => 'Weight', birthyear => 'Birthyear', birthstate => 'Birthstate', _FilterOnClickCustom1_ => 'Other Data', _FilterOnClickCustom2_ => 'More Data' ); FilterOnClickCustom $filteronclick->data_table->addRow( 'Last Name', 'First Name', 'Bats' , 'Throws' , 'Height (ft)', '(inches)', 'Weight', 'Birth Year' ); $filteronclick->params( $cgi->Vars; ); $filteronclick->exclude_from_url(); # indicate which columns to exclude, inverse of display above # can be set in config file as well $filteronclick->exclude_columns(); # indicate the base class to work with, this is optional, # if you should create you object via a call to # Class::DBI::Plugin::FilterOnClick vs. a Class::DBI sub class # this assures the correct sub class is used for data collection $filteronclick->cdbi_class( 'Baseball::Master' ); # indicate the style of navigation to provide $filteronclick->navigation_style( 'both' ); print qq~Filter by First Letter of Last Name~; print $filteronclick->string_filter_navigation( -column => 'lastname', -position => 'begins', ); print qq~~; $filteronclick->only('firstname'); print $filteronclick->build_table( _FilterOnClickCustom1_ => sub { my $pid = shift; # pid = Primary ID of the record in the base table my @status_objects = Baseball::Allstars->search(lahmanid => $pid); if (@status_objects) { my $years; foreach my $st (@status_objects) { $years .= $st->year() . " "; } return $years; } return 'NA'; }, _FilterOnClickCustom2_ => sub { my $pid = shift; # pid = Primary ID of the record in the base table my @status_objects = Baseball::Allstars->search(lahmanid => $pid); if (@status_objects) { my $teams; foreach my $st (@status_objects) { $teams .= $st->team() . " "; } return $teams; } return 'NA'; }, ); my $nav = $filteronclick->html_table_navigation(); print qq!$navn!; $filteronclick->add_bottom_span($nav); print $filteronclick->data_table;UPGRADE WARNINGAs of the .8 release there have been changes to the methods and how they work. It is likely that scripts built with older versions WILL break. Please read below to find specific changes that may negatively impact scripts built using the the releases prior to .8. The 1.0 release contains some minor modifications that could in some chases break your scripts, test carefully before upgrading in a production environment.The intention of this module is to simplify the creation of browsable and searchable HTML tables without having to write the HTML, either in your script or in templates.It is intended for use inside of other frameworks such as Embperl, Apache::ASP or even CGI. It does not aspire to be its own framework. If you are looking for a frameworks which allow using Class::DBI I suggest you look into the Maypole or the Catalyst module.See FilterOnClick below for more on the purpose of this module.Tables are created using HTML::Table. The use of HTML::Table was selected because it allows for several advanced sorting techniques that can provide for easy manipulation of the data outside of the SQL statement. This is very useful in scenarios where you want to provide/test a sort routine and not write SQL for it. The more I use this utility the less likely it seems that one would need to leverage this, but it is an option if you want to explore it.Feedback on this module, its interface, usage, documentation etc. is welcome. Requirements: · Perl


Class::DBI::Plugin::FilterOnClick Related Software