The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Tk::DBI::Table - Megawidget to display a sql-Statement in HList.

SYNOPSIS

        use Tk;
        use Tk::DBI::Table;
        
        my $top = MainWindow->new;
        my $tkdbi = $top->DBITable(
                        -sql            => 'select * from table',
                        -dbh            => $dbh,
                        -display_id     => 0,
                    )->pack(expand => 1, -fill => 'both');
        
        MainLoop;

DESCRIPTION

This is a megawidget that enables you to display sql statements from a database. The features are:

each column has a ResizeButton for flexible width
The user can activate any Button to sort the column in the directions 'ASC', 'Desc' or 'None'.
Sorted column can display with a extra style

WIDGET-SPECIFIC OPTIONS

-dbh => $dbh

A database handle, this will return a error if not defined.

-sql => 'select * from table'

A sql statement, this will return an error if not defined.

-debug [0|1]

This is a switch that turns on debug output to the normal console (STDOUT).

-display_id [Off|On]

This is a switch for displaying the index column.

-columnWidths [colWidth_0, colWidth_1, colWidth_2, ...]

Default field column width.

-maxchars number or {col1 => number}

Maximum displaying chars in the cells. Global or only in named columns.

-maxcols number

Maximum columns in this table, this replace the count of fields in sql-statment.

-srtColumnStyle(option => value)

Column sort style.

METHODS

These are the methods you can use with this Widget.

$dbitable->sql( new_sql_statement );

Set a new SQL-Statement and will display this.

$DBITree->info('anchor, bbox, children, data, dragsite, dropsite ...', $id);

This is a wrapper to the HList Method ->info. The default method is info('data', ...). Please read the manual from Tk::HList.

$dbitable->refresh( [to_sort_col_number] );

Refresh the table and sort (optional) the col number.

$dbitable->sortcol( to_sort_col_number );

Refresh the table and sort the col number or return the actually col sort number.

$dbitable->direction( ['NONE', 'ASC' or 'DESC'] );

Set a new sorting direction. no parameter will return the actual sort direction.

ADVERTISED WIDGETS

'table' => HList-Widget

This is a normal HList widget. I.e.:

        $dbitable->Subwidget('table')->configure(
                -command = sub{ printf "This is id: %s\n", $_[0] },
        };

'HB_<column number>' => Button-Widget

This is a (Resize)Button widget. This displays a Compound image with text and image.

CHANGES

$Log: Table.pm,v $ Revision 1.13 2003/11/06 17:55:52 xpix ! bugfixes in refresh_id * not hudge load for tree

Revision 1.11 2003/07/17 14:59:53 xpix ! many little bugfixes

Revision 1.8 2003/04/29 16:25:58 xpix * reformat

Revision 1.6 2003/04/29 16:22:52 xpix * chnages tag

AUTHOR

xpix@netzwert.ag

Copyright (C) 2003 , Frank (xpix) Herrmann. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

KEYWORDS

Tk::DBI::*, Tk::ResizeButton, Tk::HList