I have created my first module. I am running into an issue with my table. The headers and the row text don’t line up and the header row are not sortable
See the image, the top example shows the “Disk and Network Filesystems” Module the headers are lined up with the rows and they have those sort arrows.
My table the headers don’t line up and they are not sortable. I have searched all over to find how to do this.
Here is my code
#!/usr/bin/perl
use DBI;
use lib "/usr/libexec/webmin/client_management";
use client_management qw(read_db_config);
require './client_management-lib.pl';
# Read database configuration
my %config = read_db_config("/usr/libexec/webmin/client_management/db_config.conf");
my $dsn = "dbi:Pg:dbname=$config{db_name};host=$config{db_host}";
my $dbh = DBI->connect($dsn, $config{db_user}, $config{db_pass}, { RaiseError => 1, AutoCommit => 1 })
or die "Database connection failed: $DBI::errstr\n";
# Webmin UI header
#print &header("Client Management", undef);
print &ui_print_header("", $module_info{'desc'}, "", undef, 1, 0, 0);
# Fetch all records from the client table
my $sth = $dbh->prepare("SELECT id, name FROM client");
$sth->execute();
my $client_array = $sth->fetchall_arrayref;
# Sort by id (alphabetical)
my @sorted_id = sort { $a->[0] cmp $b->[0] } @$client_array;
if (@sorted_id) {
print &ui_columns_start([ $text{'index_id'},
$text{'index_email'},
$text{'index_clname'},
$text{'index_dparts'}]);
# Output the sorted records
foreach $idrec (@sorted_id) {
my ($id, $name) = @$idrec;
my $view_link = "<a href='view.cgi?id=$id'>$id</a>";
my $emails_link = "<a href='emails.cgi?id=$id'>$text{'emails_link'}</a>";
print &ui_columns_row([$view_link, $emails_link, $name]);
}
$sth->finish();
$dbh->disconnect();
print &ui_columns_end();
}
# Cleanup
&ui_print_footer("/", $text{'index'});
#print footer();