Edit Table Plugin

Edit TWiki tables in place, using edit fields and drop down boxes, without having to edit the complete topic.

Simply add an [ Edit table ] button to an existing table by writing %EDITTABLE{}% directly above the table. This can be added to tables that are formatted with TablePlugin: add the EDITTABLE variable just above or below the TABLE tag. It can also be used without any TABLE tag.

Customize entry fields by specifying the format: use a text field, a drop down box, a date field, radio buttons or checkboxes.

Multiple tables per topic are editable, but only one at a time can be edited.

Specify the header format of a new table like "|*Food*|*Drink*|". Useful to start a table with only a button

(no header)

helptopic

Topic name containing help text shown below the table when editing a table. The %STARTINCLUDE% and %STOPINCLUDE% variables can be used in the topic to specify what is shown.

(no help text)

include

Other topic defining the EDITTABLE parameters. The first %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)

redirectto

Set up a return page after saving changes. e.g By setting redirectto="%BASEPAGE%", you can return to base page if your editable table is included by another page.

(none)

buttonrow

Set to top to put the edit buttons above the table.

bottom

changerows

Rows can be added and removed if "on" Rows can be added but not removed if "add" Rows cannot be added or removed if "off"

CHANGEROWS plugin setting

editbutton

Set edit button text, e.g. "Edit this table"; set button image with alt text, e.g. "Edit table, %PUBURL%/%SYSTEMWEB%/TWikiDocGraphics/edittopic.gif"; hide edit button at the end of the table with "hide" (Note: Button is automatically hidden if an edit button is present in a cell)

EDITBUTTON plugin setting

javascriptinterface

Use javascript to directly move and delete row without page refresh. Enable with "on", disable with "off".

JAVASCRIPTINTERFACE plugin setting

quietsave

Quiet Save button is shown if "on", hidden if "off"

QUIETSAVE plugin setting

Using TWiki Variables in the Format Parameter

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 with format tokens if you do not want that.

Any TWiki variable inside a table cell will be preserved. For instance, %TOPIC% will not get expanded to the current topic name.

New line. Use $n() if followed by alphanumeric character, e.g. write Foo$n()Bar instead of Foo$nBar

$nop or $nop()

Is a "no operation".

$quot

Double quote (")

$percnt

Percent sign (%)

$dollar

Dollar sign ($)

Date Field Type

The date field type allows one to choose a date with a popup calendar. Popup calendar works with all modern browsers. The date picker button is inactive if the browser cannot support the popup calendar or if javascript is disabled.

Per Cell Settings

An individual edit field type can be defined for each table cell. Place an %EDITCELL{ "type, ..." }% variable at the end of the cell content. This is useful to override the per column %EDITTABLE{ format="..." }% settings, or to create tables with key/value rows. All edit field types of the format="..." parameter are supported. For example, to define a text field, type: | cell content %EDITCELL{ "text, 20" }% |

It is also possible to place the edit button inside a cell instead of default location below the table. Type | %EDITCELL{ "editbutton, 1, Edit this table" }% | to show a button, or | %EDITCELL{ "editbutton, 1, Edit table, Image-URL" }% | to show a button image with alternate text.

Note: The %EDITCELL{ }%=variable cannot be used by itself; place an =%EDITTABLE{ }%=variable at the beginning of a table where you want to use =%EDITCELL{ }% variables.

The following example shows a simple table with key/value rows. The default edit field type for the value column is a text field. This is overloaded by a selector for the Gender, and a date picker for the DOB. This is typically used by TWiki applications where new topics with tables are created based on a template topic.

Limitations and Known Issues

There is a performance issue when editing a large table, say, with more then 50 rows

You cannot put two %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: select,1,%<nop>X%,%<nop>Y%

Installation Instructions

Download the ZIP file from the Plugin web (see below)

Unzip EditTablePlugin.zip in your ($TWIKI_ROOT) directory.

Alternatively,

Manually resolve the dependencies listed below. None

The Plugin depends on the viewauth script to authenticate the user. As described in 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.

(Dakar) Visit configure in your TWiki installation, and enable the plugin in the {Plugins} section.

Test if the Plugin is correctly installed:

Check above example if there is an [ Edit table ] button below the table in above example

4.6: Kenneth Lavrsen: The plugin prevents TablePlugin from initsorting the table being edited. This is done by temporarily appending the attribute disableallsort="on" to the TABLE tag of a table being edited. Additionally all header sorting is disabled while editing a table by setting a hidden formfield sort to "off". Disabling sorting while editing is needed now that the EditTablePlugin supports moving rows up and down.

Arthur Clemens: Fixed eating of double newlines; icons for javascript buttons and interface improvements. By default the javascript interface is turned off, set JAVASCRIPTINTERFACE to use it in edit mode.