From bd38691cf092e7ad04884589a59a6891c8fafebf Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 30 Jan 2009 09:21:05 -0800 Subject: [PATCH] Perl code for user selectable columns in the data table. --- lib/WebGUI/Asset/Wobject/DataTable.pm | 1 + lib/WebGUI/Form/DataTable.pm | 7 ++++--- lib/WebGUI/i18n/English/Form_DataTable.pm | 7 +++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/WebGUI/Asset/Wobject/DataTable.pm b/lib/WebGUI/Asset/Wobject/DataTable.pm index e8f25fd93..da18f460a 100644 --- a/lib/WebGUI/Asset/Wobject/DataTable.pm +++ b/lib/WebGUI/Asset/Wobject/DataTable.pm @@ -125,6 +125,7 @@ sub getDataTemplateVars { my $self = shift; my $json = $self->getDataJson; + $self->session->log->warn($json); my $dt = JSON->new->decode($json); # Make row data more friendly to templates diff --git a/lib/WebGUI/Form/DataTable.pm b/lib/WebGUI/Form/DataTable.pm index 3ebe5678a..a43a549c9 100644 --- a/lib/WebGUI/Form/DataTable.pm +++ b/lib/WebGUI/Form/DataTable.pm @@ -122,11 +122,11 @@ sub getDataTableHtml { # Not using a datastructure and JSON.pm because of function references for "parser" my $columnDef = '{' - . qq["key" : "$column->{ key }", ] - . qq["abbr" : "$column->{ key }", ] + . qq["key" : "$column->{ key }", ] + . qq["abbr" : "$column->{ key }", ] . qq["formatter" : "$column->{ formatter }", ] . qq["resizable" : 1, ] - . qq["sortable" : 1]; + . qq["sortable" : $column->{sortable} ]; # Automatically determine the parser to use if ( $parsers{ $column->{formatter} } ) { @@ -186,6 +186,7 @@ sub getDefaultValue { columns => [ { key => "New Column", formatter => "text", + sortable => "true", }, ], rows => [ { "New Column" => "Value", }, ], diff --git a/lib/WebGUI/i18n/English/Form_DataTable.pm b/lib/WebGUI/i18n/English/Form_DataTable.pm index ad51bad68..26e80a527 100644 --- a/lib/WebGUI/i18n/English/Form_DataTable.pm +++ b/lib/WebGUI/i18n/English/Form_DataTable.pm @@ -139,6 +139,13 @@ our $I18N = { lastUpdated => 0, context => q{Button to delete a column, shown in the Edit Schema dialog}, }, + + "sortable" => { + message => q{sortable}, + lastUpdated => 0, + context => q{Whether a column is sortable in the table}, + }, + }; 1;