NAME
Tk::DBI::Tree - Megawidget to display a table column in a tree.
SYNOPSIS
use Tk;
use Tk::DBI::Tree;
my $top = MainWindow->new;
my $tkdbi = $top->DBITree(
-table => 'table',
-index => 'id',
-fields => [qw(col1 col2 col3)],
-where => 'WHERE mammut == 1',
-dbh => $dbh,
-parent_id => 'parent_id',
-start_id => 1,
)->pack(expand => 1, -fill => 'both');
MainLoop;
DESCRIPTION
This is a megawidget to display a sql statement from your database in a TreeTable. The features are: - every column has a ResizeButton for flexible width
WIDGET-SPECIFIC OPTIONS
-dbh => $dbh
A database handle, this will return a error if not defined.
-table
The table to display.
-debug [0|1]
This is a switch for debug output to the normal console (STDOUT)
-fields [col0, col1, col2, ...]
Fields to Display.
-textcolumn text
Text column to display in Tree..
-start_id
The id, was start to work on the tree.
-columnWidths [colWidth_0, colWidth_1, colWidth_2, ...]
Default width for field columns.
-maxchars number or {col1 => number}
Maximum displaying chars in the cells. Global or only in named columns. I.E.:
-maxchars => {
descr => 25,
name => 10,
},
METHODS
These are the methods you can use with this Widget.
$DBITree->refresh;
Refresh the tree.
$DBITree->close_all;
close all trees.
$DBITree->ListEntrys;
This returnd a sorted ref array with all entrys in tree.
$DBITree->select_entrys([en1, en2, en3, ...]);
This returnd an sorted ref array with all selected entrys in tree or you can give an array with entrys to select.
$DBITree->remember( $hash );
This method is very usefull, when you will remember on the last tree status and widths from the resize buttons. This returnd a ref hash with following keys, if this call without parameter.
- widths - an ref array with from every column
- stats - a ref hash with status (open close none) from every entry
You can give a old Hash (may load at program start) and the tree is remember on this values.
I.E.:
$tree->rembember( $tree->rembember );
# or ...
$tree->remember( {
status => {
'0:1' => 'open',
'0:1:2' => 'close',
...
},
widths => [165, 24, 546],
} );
ADVERTISED WIDGETS
'tree' => Tree-Widget
This is a normal Tree widget. I.e.:
$DBITree->Subwidget('tree')->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: Tree.pm,v $
AUTHOR
Copyright (C) 2003 , Frank (xpix) Herrmann. All rights reserved.
http://www.xpix.de
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::Tree, DBIx::Tree
__END__