fanticla has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
I am using TableMatrix to show data from a SQLite database. Queries may produce 2 rows of data or 1000... I'd like to change the number of rows of the table according to this value (the value should be easly get from SQLite, I think I read about a command).
Any idea on how to update (number of rows) an existing TableMatrix? I tried different approches, but nothing seems to let the TableMatrix to get updated (I hust want to avoid destroing and rebuilding the TableMatrix for every query!)
Here is my code:
sub create_table { $arrayVar = {}; ($rows,$cols) = (5000, 6); foreach my $row (0..($rows-1)){ $arrayVar->{"$row,0"} = "$row"; } foreach my $col (0..($cols-1)){ $arrayVar->{"0,$col"} = "$col"; } #Creating Table... sub colSub{ my $col = shift; return "OddCol" if( $col > 0 && $col%2) ; } $t = $frame_d->Scrolled('TableMatrix', -state=>'disabled', -rows => $rows, -cols => $cols, -width => 6, -bg=>'white', -height => 12, -titlerows => 1, -titlecols => 1, -variable => $arrayVar, -coltagcommand => \&colSub, -browsecommand => \&brscmd, -colstretchmode => 'last', -flashmode => 1, -flashtime => 2, -wrap=>1, -rowstretchmode => 'last', -selectmode => 'extended', -selecttype=>'row', -selecttitles => 0, -drawmode => 'fast', -scrollbars=>'se', -sparsearray=>0, )->pack(-expand => 'both', -fill => 'both'); }
Before a new query I just clean the table
#clear table sub clear_table{ foreach my $row(1..$rows){ foreach my $col(1..$cols){ $arrayVar->{"$row,$col"} = ""; } } }
The problem with my solution is that if a have a table with for example 3000 rows, but only 20 rows of data, the scrolling through the table is not very confortable.
Any suggestion is very much appreciated!
Cla
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: TableMatrix and dynamically set the number of rows
by lamprecht (Friar) on May 08, 2010 at 18:45 UTC | |
by Anonymous Monk on May 08, 2010 at 20:29 UTC | |
|
Re: TableMatrix and dinamically set the number of rows
by Marshall (Canon) on May 10, 2010 at 10:21 UTC |