---+!! Edit Table Plugin This plugin allows you to edit TWiki tables using edit fields and drop down boxes. Tables have an *[ Edit table ]* button if preceeded by an =%<nop>EDITTABLE{...}%= variable. Each column can be a text field, a drop down box or a row number. Multiple tables per topic are editable, but only one at a time can be edited. %TOC% ---++ Per Table Settings Add a =%<nop>EDITTABLE{...}%= variable just before an existing table to make it editable, or add the variable anywhere in a topic to start a new table. Parameters: | *Parameter* | *Comment* | *Default* | | =header= | Enable static header if ="on"=, e.g. disable editing of the first row;<br /> Else specify the header format of a new table like ="|*Food*|*Drink*|"=. | (no header) | | =format= | The format of one row when editing the table. A cell can be a text input field, a drop down box, a fixed label, or a row number. Cell definitions:%BR% - Text input field (1 line):%BR% =| text, <size>, <initial value> |= %BR% - Textarea input field:%BR% =| textarea, <rows>x<columns>, <initial value> |= %BR% - Drop down box: %BR% =| select, <size>, <option 1>, <option 2>, etc |= %BR% - Fixed label: %BR% =| label, 0, <label text> |= %BR% - Row number: %BR% =| row, <offset> |= %BR% - Date: %BR% =| date, <size>, <initial value>, <DHTML date format> |= | ="text, 16"= %BR% for all cells | | =changerows= | Rows can be added and removed if ="on"=;<br /> Rows can be added but not removed if ="add"= | =CHANGEROWS= %BR% Plugin setting | | =include= | Other topic defining the EDITTABLE parameters. The first %<nop>EDITTABLE% in the topic is used. This is useful if you have many topics with the same table format and you want to update the format in one place. | (none) | | =helptopic= | Topic name containing help text shown below the table when editing a table. The %<nop>STARTINCLUDE% and %<nop>STOPINCLUDE% variables can be used in the topic to specify what is shown. | (no help text) | __Note:__ By default, variables in =<initial value>= (of text input field) and =<label text>= (of fixed label) get expanded when a new row is added. This can be used for example to add a timestamp to a label. You can escape characters if you do not want that: | *Text:* | *To Escape:* | | =$quot= | Double quote (="=). Alternatively write =\"= to escape it | | =$percnt= | Percent sign (=%=) | | =$dollar= | Dollar sign (=$=) | | =$nop= or =$nop()= | Is a "no operation" | ---++ Table Buttons <form> * In page view mode: * <input type="submit" name="et" value="Edit table" onClick="return(false);" /> - turn the table into edit mode * In edit mode: * <input type="submit" name="etsave" value="Save table" onClick="return(false);" /> - save your changes * <input type="submit" name="etqsave" value="Quiet save" onClick="return(false);" /> - save your changes without alerting subscribed WebNotify users * <input type="submit" name="etaddrow" value="Add row" onClick="return(false);" /> - add row to the table (if enabled) * <input type="submit" name="etdelrow" value="Delete last row" onClick="return(false);" /> - remove last row from the table (if enabled) * <input type="submit" name="etcancel" value="Cancel" onClick="return(false);" /> - cancel without saving and release edit lock </form> ---++ Examples Line before table: =%<nop>EDITTABLE{ header="|*Nr*|*Text field sandbox*|*Drop down sandbox*|*Timestamp*|" format="| row, -1 | text, 20, init | select, 1, one, two, three, four | label, 0, %<nop>SERVERTIME{"$day $mon $year $hour:$min"}% |" changerows="on" }%= %EDITTABLE{ header="|*Nr*|*Text field sandbox*|*Drop down sandbox*|*Timestamp*|" format="| row, -1 | text, 20, init | select, 1, one, two, three, four | label, 0, %SERVERTIME{"$day $mon $year $hour:$min"}% |" changerows="on" }% |*Nr*|*Text field sandbox*|*Drop down sandbox*|*Timestamp*| | 1 | hello table | one | 26 Jun 2002 12:30 | | 2 | | two | 27 Jun 2002 12:40 | If this plugin is installed you will see an *[ Edit table ]* button above; when you click on it you get this form: <form> <table border="1" cellspacing="1" cellpadding="0"> <tr><th bgcolor="#99CCCC"> Nr </th><th bgcolor="#99CCCC"> Text field sandbox </th><th bgcolor="#99CCCC"> Drop down sandbox </th><th bgcolor="#99CCCC"> Timestamp </th></tr> <tr><td bgcolor="#FFFFFF"> 1<input type="hidden" name="etcell2x1" value="1" /> </td><td bgcolor="#FFFFFF"> <input type="text" name="etcell2x2" size="20" value="hello table" /> </td><td bgcolor="#FFFFFF"> <select name="etcell2x3" size="1"> <option selected="selected">one</option> <option>two</option> <option>three</option> <option>four</option> </select> </td><td bgcolor="#FFFFFF"> 26 Jun 2002 12:30<input type="hidden" name="etcell2x4" value="26 Jun 2002 12:30" /> </td></tr> <tr><td bgcolor="#FFFF99"> 2<input type="hidden" name="etcell3x1" value="2" /> </td><td bgcolor="#FFFF99"> <input type="text" name="etcell3x2" size="20" value="" /> </td><td bgcolor="#FFFF99"> <select name="etcell3x3" size="1"> <option>one</option> <option selected="selected">two</option> <option>three</option> <option>four</option> </select> </td><td bgcolor="#FFFF99"> 27 Jun 2002 12:40<input type="hidden" name="etcell3x4" value="27 Jun 2002 12:40" /> </td></tr> </table> <input type="submit" name="etsave" value="Save table" onClick="return(false);" /> <input type="submit" name="etqsave" value="Quiet save" onClick="return(false);" /> <input type="submit" name="etaddrow" value="Add row" onClick="return(false);" /> <input type="submit" name="etdelrow" value="Delete last row" onClick="return(false);" /> <input type="submit" name="etcancel" value="Cancel" onClick="return(false);" /> (demo only, these buttons do not work) </form> ---+++ Date Field Type <img src="%ATTACHURLPATH%/EditTablePluginCalendarExample.gif" alt="Edit Table Calendar Example" width="549" height="210" align="left" /> The =date= field type allows one to choose a date with a popup calendar. Popup calendar works for Netscape 6.0 or better, all other Gecko-based browsers, Internet Explorer 5.0 or better for Windows, Opera 7 and Konqueror 3.1.2. The =...= button is inactive if the browser cannot support the popup calendar. It uses the nice [[http://dynarch.com/mishoo/calendar.epl][Mishoo DHTML calendar]], see also TWiki:Codev/JavaScriptDatePickerForForm <br clear="all"> ---++ Plugin Settings Plugin settings are stored as preferences variables. To reference a plugin setting write ==%<nop><plugin>_<setting>%==, for example, ==%<nop>EDITTABLEPLUGIN_SHORTDESCRIPTION%== * One line description, shown in the %TWIKIWEB%.TextFormattingRules topic: * Set SHORTDESCRIPTION = Edit TWiki tables using edit fields and drop down boxes * Set DEBUG to 1 to get debug messages in =data/debug.txt=. Default: =0= * Set DEBUG = 0 * Default for change rows flag: =on=, =off=, =add= * Set CHANGEROWS = on * Date format of [[http://dynarch.com/mishoo/calendar.epl][Mishoo DHTML calendar]]: * Set JSCALENDARDATEFORMAT = %Y/%m/%d * Language of DHTML calendar, pointing to attached =calendar-<code>.js= language file: =en=, =de=, =es=, =fr=, =jp= * Set JSCALENDARLANGUAGE = en * Additional options of DHTML calendar: * Set JSCALENDAROPTIONS = __Note:__ The Plugin looks for the =JSCALENDAR*= settings first in the TWiki Preferences, then in above Plugin settings ---++ Limitations and Known Issues * This Plugin does not support TWiki table formatting like Multi-span cells (e.g. =| ... ||=) and cell justification (e.g. =| centered | right |=). * There is a performance issue when editing a large table, say, with more then 50 rows. * The Plugin fails if the table is at the very end of the topic (without a new line) Always ensure there is a newline after the table * Variables like =%<nop>ATTACHURL%= get expanded unless they are in a label. * %RED% *Warning:* %ENDCOLOR% This plugin uses undocumented functions to read, save and lock a topic. The plugin will likely break in a future TWiki release. * You cannot put two %<nop>EDITTABLE% statements on the same line in the source. * You can include %-vars now in select values, by quoting them with <nop>, as in %<nop>X% for %X%, say for instance: <br /> =select,1,%<nop>X%,%<nop>Y%= ---++ Plugin Installation Instructions __Note:__ You do not need to install anything on the browser to use this Plugin. The following instructions are for the administrator who installs the plugin on the server where TWiki is running. * Download the ZIP file from the Plugin web (see below) * Unzip ==%TOPIC%.zip== in your twiki installation directory. Content: | *File:* | *Description:* | | ==data/TWiki/%TOPIC%.txt== | Plugin topic | | ==data/TWiki/%TOPIC%.txt,v== | Plugin topic repository | | ==lib/TWiki/Plugins/%TOPIC%.pm== | Plugin Perl module | * The plugin depends on the =viewauth= script to authenticate the user. As described in %TWIKIWEB%.TWikiAccessControl, copy the =view= script to =viewauth= (or better, create a symbolic link) and add =viewauth= to the list of authenticated scripts in the =.htaccess= file. * The Mishoo DHTML calendar 0.9.5 is preinstalled and should work without any configuration. If you wish to use another language, attach the language files to the Plugin topic and change the Plugin settings * Test if the plugin is correctly installed: * Check above example if there is an *[ Edit table ]* button below the table in above example * Click on *[ Edit table ]*, make changes and save the table ---++ License * The Edit Table Plugin is released under the [[http://www.gnu.org/licenses/gpl.html][GPL]] * The [[http://dynarch.com/mishoo/calendar.epl][Mishoo DHTML calendar]] bundled with this Plugin was created by Mihai Bazon and is released under the [[http://www.gnu.org/licenses/lgpl.html][LGPL]] -- thanks Mihai for the great tool :-) ---++ Plugin Info | Plugin Author: | TWiki:Main/PeterThoeny | | Plugin Version: | 13 Dec 2003 | | Change History: | <!-- specify latest version first --> | | 13 Dec 2003: | Added CHANGEROWS, JSCALENDARDATEFORMAT, JSCALENDARLANGUAGE, JSCALENDAROPTIONS settings | | 16 Oct 2003: | small typo fixed (garbled if ---<nop>+ header on top) | | 15 Oct 2003: | new date field type with javascript calendar - CN | | 14 Oct 2003: | docfix: the documentation page was an old one - CN | | 13 Oct 2003: | bugfix: %-vars in select were resetted to first on add/del row - CN | | 18 Sep 2003: | incompatibility: changed default of =changerows= to =on=; support for %-vars, Quiet save for saving without notification; all other fixes in Dev topic integrated - CN | | 08 Nov 2002: | Prevent variable expansion in label text; added escape characters | | 27 Jun 2002: | New =helptopic= parameter | | 26 Jun 2002: | Support for variables in included EDITTABLE parameters; fixed problem with HTML in cells | | 21 May 2002: | Added fixed label format; new =changerows="add"= parameter | | 27 Apr 2002: | Fixed bug where text after a double quote in a cell disappeared | | 18 Apr 2002: | Fixed bug where table was breaking when pasting multiple lines into an edit field using Netscape on Unix | | 08 Apr 2002: | Check for change permission and edit lock of topic | | 05 Apr 2002: | Initial version | | CPAN Dependencies: | none | | Other Dependencies: | [[http://dynarch.com/mishoo/calendar.epl][Mishoo DHTML calendar]] (version 0.9.5 preinstalled) | | Perl Version: | 5.0 | | Plugin Home: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC% | | Feedback: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Dev | __Related Topics:__ %TWIKIWEB%.TWikiPreferences, %TWIKIWEB%.TWikiPlugins -- TWiki:Main/PeterThoeny - 13 Dec 2003
This topic: TWiki
>
EditTablePlugin
Topic revision: r2 - 2003-12-14 - PeterThoeny
Copyright © 1999-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback
Note:
Please contribute updates to this topic on TWiki.org at
TWiki:TWiki.EditTablePlugin
.