'description' => 'ABS package with revA firmware. Used in low-cost applications and as replacement for model UX34AT. Includes adaptor wiring harness for UX34AT',
This module was developed to simplify the manipuation of complex tabular data in engineering and business-process web applications. The motivation was a rapid-prototype software development flow where the requirements gathering phase goes something like "I have this big complicated spreadsheet that I want to make a website out of..., can you help?". The EditableTable class is an 'abstract' base class and EditableTable::Horizontal and EditableTable::Vertical are the implementations for two commonly used table types. Key features of these classes are as follows:
- methods to generate javascript for dynamic addition and remove of rows and commonly needed features such as 'click-to-expand' text display, calendar widget date entry, and sorting
For the Horizontal table, data are provided to tables in an array-of-hashes (most common case) or a hash-of-hashes. For the Vertical table, a single hash of data produces a single column of data while a hash-of-hashes supports muliple data columns.
Common constructor for EditableTable-derived classes. Providing the required initialization data to new() can be done either by a hashref to table-level parameters or by calling the required set*() methods prior to rendering the table with htmlDisplay(). The following examples detail the minimum requirements for configuring an EditableTable.
a hashref of hashrefs - this allows sorting the rows by hash key. This structure is allowable for EditableTable::Horizontal and multi-column Editable::Vertical. See L"SORTING"> for details.
Required parameter. An arrayref of hashrefs to parameters for each table field. Fields are presented left-to-right in array order for Horizontal tables and top-to-bottom for Vertical Tables. See L"TABLE FIELD PARAMETERS"> for documentation of the field parameters.
Required parameter. Set the table mode to 'view' or 'edit'. In 'view' mode, a table field is reprsented by text. In 'edit' mode, the a field is represented by 'its formElement' parameter.
By default, EditableTable's htmlDisplay and htmlJavascriptDisplay method will output to STDOUT. If stringOutput is set to 1 or 'true', then htmlDisplay will return a string with the table html.
if (ref($sortHeader)) { confess "the sort header is a string with the url leading up to the name of the column you wish to sort by, this is a " . ref($sortHeader); }
When set, EditableTable will sort the $self->{data} server-side. Often this is unecessary as the data will have been presorted using SQL, but for small tables this is less work and is self-contained to the EditableTable class.
Use when the EditableTable needs to be integrated with other form elements and the tabindex isn't desirable. This sets all the tabindex values for formElemnts to the specified number, which will result in the browser default behavior being applied to the table but in the correct order with other form elements. An reference is used in case the behavior of this method is changed in the future.
By default, a rowspanned table will flatten in 'edit' mode, with the rowspanning column repeated for each of the spanned rows. This is done to enable editing of the relationship betwen the fields and to preserve unique ids. If this is not the desired behavior, use this method to preserve the rowspanning in 'edit' mode.
For Horizontal tables with a hash of hashes data structure, this sorts the rows per the provided arrayref. For Vertical tables with multiple data columns, sorts the columns left-to-right per the provided arrayref.
if (ref($sortOrder ne 'ARRAY')) { confess "the sort order must be a reference to an array of the dataset keys which will used to determine the row order"; }
Returns the directory for installation of www.dynarch.com jscalendar-1.0, which is supported in the 'calendar' formElement. Defaults to 'jscalendar' if not set.
This method can be used to override the default javascript object. Inherit from HTML::EditableTable::Javascript and provide an object reference to your table prior to calling htmlJavascriptDisplay(). If this method is not used, the default class will be used to create a javascript object. See L"JAVASCRIPT INTEGRATION"> for more details.
Specifies the data hash key for provided data for the table element. Also Specifies the form element base name that will be used. Typically, this is also a database field name.
calendar - Implements popup calendar using www.dynarch.com jscalendar 1.0. Requires this javascript library to be accessible. See L"JAVASCRIPT INTEGRATION"> for details.
html5Calendar - Alternative to calendar. Implements HTML5 'date' input type. Tested with Opera, which is the only browser supporting this HTML5 input as of this writing.
Sets the field whose 'dbfield' value is used to provide a unique name and id to other form elements in the same array (row or column, depending on the implementation) of data. This is done by appending an '_' and then the value of the specified dbfield. Typically, the 'dbfield' is a database table's unique 'id' field.
Implements a javascript which truncates the text and provides a toggle to switch between full and truncated text. The value sets the number of characters which are displayed in 'truncated' mode.
Provides a mechanism to process data with a custom function or method prior to display. Typically used for custom formatting, setting table values based on other values, or 'child' database queries.
Determines how checkboxes will behave when toggling between view and edit modes. Valid values are 'checked', 'checkedOnVal', and checkedOnTrue'. The later value will result in the checkbox being checked if the data value matches the pattern /^1|true|yes$/i
Sometimes used to sub tags for \n when presenting text data. Common use case is when a user cut and pastes an email into a textarea. In 'view' mode, 'subBr' will keep the email's formatting
For a textfield input tag, sets the maximum number of characters which can be input. Sets the 'maxLength' html tag parameter. This defaults to 255 if no value is provided, the reasoning being the most textfields are mapped to a VARCHAR database datatype with a 255 char limit.
For horizontal tables only. Provides a 'clear column' button in the column header to clear text from all fields in the column when the table is in 'edit' mode.
In table 'edit' mode, the default textfield width is 2X the value with a minimum value of 60 char. If 'minimalEditSize' is set, this reduces to 1.2X the value with a minium value of 15. In large tables, minimalEditSize helps keep the presentation clean.
Rowspanning is sometimes done by creators of spreadsheets that are to be converted to web applications. The data for these cases is a hierarchical array of hashrefs. This parameter provides the name of the second level hash key which contains the nested data to be rowspanned. The 'dbfield' parameter is used to specify the top level key to the second level of data to be rowspanned.
For rowspanning tables. In 'edit' mode, it is critical to produce a traceable field id for elements that are rowspanned. The most simple way to do this is by specifing this parameter to be a member of the nested rowspanned data. Working from the previous example:
produces a table with the following unique id's in 'edit' mode. Note the flattening of the table in 'edit' mode. If this is not desired set the table-level flag 'rowspannedEdit'.
This parameter can be combined with uniquifierField to produce a expanded unique id. This is handy when the rowspanned data cannot produce a unique field id or a binding relationship needs to be maintained.
produces a table with the following unique id's in 'edit' mode. Note the flattening of the table in 'edit' mode. If this is not desired set the table-level param 'rowspannedEdit'.
When rowspanned tables are switched to 'edit' mode, the table is flattened to provide the ability to change the relationships which create the spanning. To provide traceability for the fields which span, combine this parameter with rowspanArrayUniquifier (described above) to specify the first and second level keys of the data hierarchy to used for field name and id construction.
produces a table with the following unique id's in 'edit' mode. Note the flattening of the table in 'edit' mode. If this is not desired set the table-level param 'rowspannedEdit'.
The final field name and id generation parameter. If specified, uses the 'class static' field counter to append a final id to the field name. Useful when adding rows of new data to a table where this is needed to ensure a unique id is created.
produces a table with the following unique id's in 'edit' mode. Note the flattening of the table in 'edit' mode. If this is not desired set the table-level param 'rowspannedEdit'.
The javascript features are encapsulated in HTML::EditableTable::Javascript. Each method provided by this class provides a distinct javascript feature, allowing for clean override or extension. The intent is to provide all javascript functionality "under the hood" via table and table-field parameter setting. If not specified by the user, the Javascript object is created by the table. This leads to the the javascript