Neumann & Kamp
System  EditRowPlugin (compare)

Difference: EditRowPlugin (r2 vs. r1)

EditRowPlugin

Replacement for some of EditTablePlugin, some of EditTablerowPlugin and some of TablePlugin.

screenshot.gif

A replacement for most of EditTablePlugin, some of EditTablerowPlugin and some of TablePlugin. Features:

  1. You can edit one row row, or even one cell at a time, instead of having to edit the entire table. This solves the problem with the long page rendering times required to show all the HTML for a full table edit on big tables.
  2. Row being edited can be presented horizontally, as with EditTablePlugin, or Form-style, like EditTablerowPlugin. Makes it easier to edit very wide tables.
  3. Supports footer rows.
  4. Supports sorting columns in tables using Javascript, avoiding the round-trip to the server required by TablePlugin. Can fall back to TablePlugin if Javascript isn't available.
  5. Simple interface to moving rows around in the table, deleting and adding rows.
  6. Gets row numbering right (takes account of headers).
  7. It's faster than the individual plugins it replaces. much faster than the individual plugins it replaces.
  8. (geeky) Coded using a clean object-oriented architecture, which makes it easily extensible.
  9. (geeky) Uses a simple REST interface for saving changes, which allows Javascript table editors to use the same interface to save.
  10. (geeky) Tolerant to Javascript being disabled in the browser

Note that this plugin is designed for use with tables of up to ~1000 rows. Tables larger than this will work, but they put considerable stress on the browser and the server. For manipulating larger tables, you are recommended to investigate Foswiki:Extensions.JQGridPlugin.

Usage

Works like the EditTablePlugin (it uses exactly the same %EDITTABLEtags) macro) and you can use it to edit the entire table, or just one row at a time.

A An %EDITTABLE{...}% in the topic will be associated with the next table in the topic. If there is no existing table, or another %EDITTABLE{...}% is seen before the next table, then a new table will be created.

Parameters:

  • format - The format of the cells in a row of the table. The format is defined like a table row, where the cell data specify the type for each cell. For example, format="| text,16 | label |". Cells can be any of the following types:
    • text, , Simple text field. Initial value is optional.
    • textarea, x, Multirow text box. Initial value is optional.
    • select, , Select one from a list of choices.
    • radio, , etc. Radio buttons. size indicates the number of buttons per line in edit mode.
    • checkbox, , Checkboxes. size indicates the number of buttons per line in edit mode.
    • label, 0, Fixed label.
    • row The row number, automatically worked out.
    • date, , , Date. Initial value and date format are both optional.
  • changerows - Rows can be added and removed if "on". Rows can be added but not removed if "add". Defaults to the value of the preference CHANGEROWS, or off "on" if it isn't set.
  • disable - By default, the plugin shows both full table and individual row editing controls. You can choose to disable one or both of these modes using the disable parameter, by setting it to row or full (or row,full to disable all editing and just leave sorting). If full table editing is disabled, but changerows is on, then the (edit table) button will be replaced with a (add row) button. Defaults to the value of the preference EDITROWPLUGIN_DISABLE, or none if it isn't set.
  • buttons - set to left (the default) or right to position edit controls in the first or last columns in the table. buttons="right" may be required if you are using other plugins that expect a certain column order.
  • quietsave - Quiet Save button is shown if "on". Defaults to the value of the preference QUIETSAVE, or off if it isn't set.
  • include - Name of another 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.
  • headerrows - Number of rows to treat as headers. Header rows are not editable, and will not be sorted. headerislabel is also supported for EditTablePlugin compatibility (equivalent to headerrows="1") |
  • header - Specify the single-row header format of a new table. For example, "|*Food*|*Drink*|". Provided for compatibility with to allow you to create a new table in a document, and to have a header that is truely readonly. EditTablePlugin, not recommended.
  • footerrows - Number of rows to treat as footers. Footer rows are not editable and will not be sorted. |
  • orientrowedit - unique to EditRowPlugin, this parameter controls the orientation of a row when it is being edited. It can be set to horizontal (the default) or vertical, which will present the columns of the row as rows in the editor. This makes editing very wide tables much easier. Has no effect in whole table editing mode.
  • helptopic Topic name containing help text shown when editing a table. The %STARTINCLUDE% and %STOPINCLUDE% markers can be used in the topic to specify what is shown. Note that newlines are removed from the included text so the that text can be used inside a table.
  • js gives local, per-table control over the EDITROWPLUGIN_JS preference described below.

Table rows are shown with a row edit button edittopic in the first column, and a table edit button after the table. When the table is edited, then a number of buttons may be shown depending on the settings of changerows and quietsave.

  • save saves the changes
  • saves without notification
  • plusadds a new row after the current row, taking for its contents whatever you entered into the current row initial values specified in the EDITTABLE macro
  • minus deletes the row
  • arrowup Move this row up one row in the table
  • arrowdown Move this row down one row in the table
  • stop cancels the open edit

Per Cell Settings

An individual edit field type can be defined for each individual table cell. Place an %EDITCELL{ "type, ..." }%variable macro 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" }% |

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

Examples

Copy the following examples and paste them into a topic in the Sandbox web (or another web where you have write access). The EditRowPlugin is not enabled on this site, so the examples will be disabled.

Example 1

%EDITTABLE{ format="| row, -1 | text, 20, init | select, 1, not started, starting, ongoing, completed | radio, 3,:-),:-I,:-( | date, 20 |" changerows="on" quietsave="on"}%
| *Nr* | *Project* | *State* | *Progress* | *Timestamp* |
| 1 | Sliced yoghourt | completed | :-) | 26 Jun 2002 |
| 2 | Cubical turkeys | not started | :-( | 27 Oct 2007 |
| 3 | Self-eating burritos | ongoing | :-D | 1 Apr 2008 | 
| 4 | Unified field theory | completed | :-) | 1 Apr 2012 |

Example 2Example 1

Example 2

%EDITTABLE{ format="| label,12 | textarea, 3x30 |" }%
| *Model* | *Description* |
| 345TG66 | Short, with sightly concave upper surface, and devilish nuts |
| 9A-11 | A new model for 2007, but not quite as pretty as the 9A-10 |
| RR717-D | Solid performer, dependable in vacuum grinders |

Example 1Example 1

Example 3

%EDITTABLE{ format="| text,100 | text,100 |" orientrowedit="vertical" headerislabel="on"}%
| *Line* | *Explanation* |
| He took his _vorpal_ sword in hand | A vorpal sword is made from broken bits of Commodore 64 disk-drives |
| Long time the _manxome_ foe he sought | manxome: possibly from 'manky'; or from the Isle of Man |
| So rested he by the _Tumtum_ tree, | Tumtum is a Nilo-Saharan language and people |
| And stood awhile in _thought_ | _thought_ a process not often employed by example writers |

Example 3Example 3

Example 4

%EDITTABLE{ format="| label | text, 40 |" }%
|*Key*|*Value*|
| Name: | John Smith |
| Gender: | M %EDITCELL{select, 1, , F, M}% |
| DOB: | 18 October 2007 %EDITCELL{date, 10}% |
| City: | New York |

Example 4Example 4

Javascript Editing

%EDITTABLE{ format="| text,12 | textarea, 3x30 |" js="assumed"}%

When a table is editable and Javascript is enabled, then when the user rolls the mouse over a table row:

  • individual table cells have a yellow stain on the corner that can be clicked to open an in-place editor,
  • table rows that contain at least one editable cell can be manually sorted using drag-and-drop, by dragging the (though beware that a TABLE tag with an initsort will override this, which can be confusing),

Table columns can be sorted in the browser, by clicking the heading above the row.

Note that javascript editing is automatically disabled if:

  • The current user does not have CHANGE access to the topic
  • No user is logged in, but the rest script is listed in the {AuthScripts} admin setting.

Preferences

The plugin interprets a couple of preferences, in common with the EditTablePlugin.

QUIETSAVE Gives a default value for the quietsave parameter. Default is off.
CHANGEROWS Gives a default value for the changerows parameter. Default is off on .

Also, the plugin can be selectively disabled using has a couple of its own settings:

EDITROWPLUGIN_DISABLE EDITROWPLUGIN_JS Set Usually the plugin expects to be able to use Javascript to generate controls. However sometimes users disable Javascript in the browser, so the plugin also generates a minimal set of fallback controls to give non-JS access to the main features, even if Javascript is disabled. You can use this preference to control whether Javascript is preferred, ignored, or assumed when generating the controls. on
  • preferred means "use JS if it's available, but keep the non-JS fallback controls visible",
  • ignored means "never use JS, only display the non-JS controls",
  • assumed means "assume that JS will be available in the browser, and don't display the fallback controls".
to disable You can control the plugin. Default is setting on a per-table basis using the off js . parameter to the EDITTABLE macro.
EDITROWPLUGIN_DISABLE Set to on to disable the plugin. Default is off.

These preferences can be defined in SitePreferences, in WebPreferences for an individual web, or in the topic.

There is also a configure (expert) setting that allows you to change the name of the macro used to carry table editor parameters. This is usually EDITTABLE but can be changed to help work around problems with other plugins.

Relationships Installation Instructions

You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server.

Open configure, and open the "Extensions" section. Use "Find More Extensions" to get a list of available extensions. Select "Install".

If you have any problems, or if the extension isn't available in configure, then you can still install manually from the command-line. See http://foswiki.org/Support/ManuallyInstallingExtensions for more help.

Using the REST API

The plugin provides a couple of useful REST handlers. Javascript developers may find this API useful when developing their own tools that manipulate tables.

There are two entry points, get and save. The get handler can be used to retrieve the contents of a table. Parameters are:

  • erp_topic the web.wikiname of the topic
  • erp_table the table (numbered from 1)
  • erp_row - the row (numbered from 1)
  • erp_col - the column (numbered from 1)

The handler returns a row, a column, or the entire table depending on the presence of the erp_row and erp_col parameters. If neither is given, the entire table is returned. If only erp_row is given, just that row will be returned, etc. The data is returned in JSON format.

For example, a URI to retrieve column 2 from the table EDITTABLE_1 from this topic would look like this:

The save handler is used to save cells, and accepts the following parameters:

  • erp_topic the web.wikiname of the topic to be changed
  • erp_table the table to be changed (numbered from 1)
  • erp_row - the row to be changed (numbered from 1, or -1 for the whole table)
  • saveRowCmd.x - if nonzero, this is a save
  • saveRowQuietlyCmd.x - if nonzero, this is a quietsave
  • upRowCmd.x - if nonzero, this is a row move
  • downRowCmd.x - if nonzero, this is a row move
  • deleteRowCmd.x - if nonzero, this is a row deletion
  • cancelCmd.x - if nonzero, this is a cancel
  • noredirect - if set, suppresses the redirect and gets a status code instead

The value of each individual cell is stored in a parameter called erp_

__

Relationship to other plugins

EditTablePlugin

At this time most features of EditTablePlugin are supported. Known exceptions are:

  • the editbutton parameter,
  • Plugin preferences (though global preferences are compatible)

TablePlugin

Javascript sorting in EditRowPlugin is much faster than TablePlugin. However TablePlugin has many features this plugin does not support. The For the most part, the two plugins can safely be used together. However if you use a TABLE statement with an initsort parameter, it is likely to cause great confusion, as the table will be re-sorted each time a row is opened for edit, and when the table is edited in full table mode.

EditTablerowPlugin

Provides the vertical row editing interface like EditTablerowPlugin, with the row being edited shown in context in the table.

Installation Instructions

You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server.

Open configure, and open the "Extensions" section. Use "Find More Extensions" to get a list of available extensions. Select "Install".

If you have any problems, or if the extension isn't available in configure, then you can still install manually from the command-line. See http://foswiki.org/Support/ManuallyInstallingExtensions for more help.

Using the REST interface

The plugin saves changes to tables via a REST handler. Javascript developers may find this interface useful when developing their own tools that manipulate tables.

The REST handler is invoked using the following URI format:

/rest/EditRowPlugin/save

The handler accepts the following parameters:

  • erp_active_topic the web.wikiname of the topic to be changed
  • erp_active_table the table to be changed (numbered from 1)
  • erp_active_row - the row to be changed (numbered from 1, or -1 for the whole table)
  • erp_active_format - the format parameter from the EDITTABLE tag
  • erp_save.x - if nonzero, this is a save
  • erp_quietSave.x - if nonzero, this is a quietsave
  • erp_upRow.x - if nonzero, this is a row move
  • erp_downRow.x - if nonzero, this is a row move
  • erp_deleteRow.x - if nonzero, this is a row deletion
  • erp_cancel.x - if nonzero, this is a cancel
  • erp_noredirect - if set, suppresses the redirect and gets a status code instead

The value of each individual cell is stored in a parameter called erp_

__

Plugin Info

Another great Foswiki extension from the WikiRing - working together to improve your wiki experience!

Plugin Author(s): Crawford Currie http://c-dot.co.uk
Plugin Version: 2665 v3.0.6 (24 Feb 2009)
Copyright: Release: © 2007 WindRiver 12 Nov 2013 Inc.
License: Copyright: GPL (Gnu General Public License) © 2007-2011 WindRiver Inc.
© 2008-2013 Foswiki Contributors
Change License: History:   GPL (Gnu General Public License)
24 Feb Change History: 2009 Foswikitask:Item1139   : fixed restoration of labels after an edit Foswikitask:Item1140: fixed loading of multi-valued parameters
15 Feb 2009 3.0.6 (13 Nov 2013) Foswikitask:Item451 Foswiki:Tasks/Item11920 : ported to foswiki syntax error in JS was causing failure on IE 7 Foswikitask:Item5757: not respecting footer rows when saving Foswikitask:Item5681: help not fully rendered before inclusion in a TML table Foswikitask:Item1086: Macros were being expanded before editing Foswikitask:Item5924: refactor for reusability
15 May 2008: 3.0.5 (12 Nov 2013) TWikibug:Item5621 Foswiki:Tasks/Item12654 : helptopics were getting munged because of use of BR to Fixed interactive row moving, add wait cursor during REST request replace newlines. This was to prevent accidental table concatenation, but breaks other things worse so I removed it. TWikibug:Item5624: handle comments with embedded tables. TWikibug:Item5625: don't count generated tables in the table count. TWikibug:Item5594: typo was causing strange behaviour with row management tools. TWikibug:Item5595: fixed problem with included tables. TWikibug:Item5596: changed default behaviour for empty cells to ignore pre-existing spaces if there is no other content. TWikibug:Item5616: row moving was failing on 4.1.2 due to bad URL construction.
8 Mar 2008 3.0.4 (11 Nov 2013) TWikibug:Item5386 Foswiki:Tasks/Item12132 : fixed Workaround for CSS problem with in editing of tables embedded from an included topic TWikibug:Item5043 PatternSkin : added Jeff Crawford's patch to fix multiline textareas
4 3.0.3 (8 Jan 2008 2013) TWikibug:Item5320 Foswiki:Tasks/Item12144 : fixed destructive save when add row is pressed foswikiIcon to icons outside edit mode Foswiki:Tasks/Item12148: added missing tooltips, changed stain cursor to match button behaviour
13 Dec 2007 3.0.2 (19 Aug 2012) TWikibug:Item4970 Foswiki:Tasks/Item10770 : removed beforeCommonTagsHandler, which was causing problems Don't expand macros in select values when interacting with other plugins that use unregistered tag handlers.
23 Nov 2007 3.0.1 (28 Jan 2012) TWikibug:Item4853 Foswiki:Tasks/Item11381 : remove duplicated %EDITCELL automatically disable JS if rest script is in {AuthScripts} and no-one is logged in
9 Nov 2007 3.0.0 (8 Dec 2011) TWikibug:Item4947 Foswiki:Tasks/Item11140 : added recoded missing _src.js versions to MANIFEST only instrument the table when the rows are actually rolled over. Reduced the amount of HTML generated by the server enormously. Added REST API.
6 Nov 2007 2.2.9 (7 Oct 2011) TWikibug:Item4935 Foswiki:Tasks/Item11140 : fixed problem optimisations for use with embedded TWiki variables very large tables Foswiki:Tasks/Item11342: added REST handler to get cell contents for editing
20 Oct 2007 2.2.8 (8 Aug 2011) TWikibug:Item4853 Foswiki:Tasks/Item11028 : support %EDITCELL JS date editor now picks up existing value TWikibug:Item4861 Foswiki:Tasks/Item11029 : rework the rules for associating tag with adjacent JS date editor now uses consistent date formats table TWikibug:Item4862: avoid expanding TWiki variables on edit
18 Oct 2007 2.2.7 (03 Aug 2011) TWikibug:Item4834 Foswiki:Tasks/Item11010 : added automatic save on row add better default for editable cell width TWikibug:Item4853 Foswiki:Tasks/Item11018 : added %EDITCELL support fixed date format in non-JS edit mode TWikibug:Item4651: fixed validation of date change
26 Sep 2007 2.2.6 (18 Jul 2011) TWikibug:Item4696 Foswiki:Tasks/Item10982 Keep table in full-table edit mode after a row is added : fix crash when adding rows with date fields that have no default value TWikibug:Item4651 add JS to handle navigating away with pending changes (requires BehaviourContrib)
10 Sep 2007 2.2.5 (27 Jun 2011) TWikibug:Item4552 Foswiki:Tasks/Item10915 Can use row buttons to delete : fix EDITCELL handling on save. the header, even though headerrows is set TWikibug:Item4565 Foswiki:Tasks/Item10922 "row" parameter not supported : abort save on clash with a synchronous edit by another user TWikibug:Item4567 header parameter not correctly handled TWikibug:Item4602 Header row gets eaten
13685 2.2.4 (14 Jun 2011) TWikibug:Item4040 Foswiki:Tasks/Item10876 Support for : return to non-edit mode after row move invokes authentication. helptopicFoswiki:Tasks/Item10876and : fix textarea. disable, which allows more flexible configuration of the UI, especially when vertical editing
13641 2.2.3 (10 Jun 2011) TWikibug:Item4020 Foswiki:Tasks/Item10862 Improved the table anchors : pick up initial values for a better editing all field types. experience. Fixed calendar formats. Fixed table footer sorting. Disabled label edits. Fixed multi-malued checkboxes. Foswiki:Tasks/Item10864: protect full-table edits when adding and removing rows. Foswiki:Tasks/Item10865: remove edit stain from label cells.
13615 2.2.2 (7 Jun 2011) TWikibug:Item3882 Foswiki:Tasks/Item10853 added initial : Remove values support TWikibug:Item4009REQUIRE_JS and =require_jsfixed included , add tables. Also fixed a bug with variable expansion reported in the dev topic. js and EDITROWPLUGIN_JS to improve support of non-JS environments
13609 2.2.1 (3 Jun 2011) TWikibug:Item4003 Foswiki:Tasks/Item10821 : fixed colspan. Also stop yellow stain added support for headerrows and footerrows parameters from %TABLE overlaying pop-up calendar. Foswiki:Tasks/Item10822: fix auth of single-cell edit
13560 2.2.0 (25 May 2011) TWikibug:Item4002 Foswiki:Tasks/Item2016 Problems with blank lines, multi-value edits, and line continuations resolved : work around core code limitations when cell content is 0; Foswiki:Tasks/Item10591: silence noisy "Click to edit" statements; change to a control for editing cells, due to the "wikiword selection" problem Foswiki:Tasks/Item10592: row move now uses an external handle, to allow for cursor select of table contents. Add feedback for saves. Foswiki:Tasks/Item10768: fix edit/save buttons in IE 7; Foswiki:Tasks/Item10777: make sure full table edit is working, and there is no risk of data loss when adding/removing rows
13596 2.1.4 (18 May 2011) TWikibug:Item4000 Foswiki:Tasks/Item10752 Added : fix HTML comments in cells orientroweditFoswiki:Tasks/Item10753, global control options, fixed : correct interpretation of changerows="add" issue with wikiwords in edited data, added column sorting
13487 2.1.3 (19 Apr 2011) TWikibug:Item3925 Foswiki:Tasks/Item10583 - fixed infinite loop when included format doesn't : support for sort order in select cells exist Foswiki:Tasks/Item10583: fixes for EDITCELL
13359 2.1.2 (14 Mar 2011) TWikibug:Item3875 Foswiki:Tasks/Item2016 - can : editor now edit top row of tables. Also now writes row numbers back to the topic, which was needed to support some compatible apps. not handling a table cell that contained only "0" correctly
13335 2.1.1 (25 Feb 2011) Fixed broken date Some minor tweaks prompt, and problem with radio buttons, improved and documented REST interface for Javascript authors
13291 2.1.0 (21 Feb 2011) Added full table editing, including moving rows within the table Foswiki:Tasks/Item5618: Foswiki:Tasks/Item5714: Foswiki:Tasks/Item5715: row moves and single-cell edits are now done client-side as much as possible. Row moves are drag and drop. Using JS lets us maintain the column numbering so that other plugins still work (e.g. table plugin init sort) as well as being a lot faster. Foswiki:Tasks/Item10363: Support button placement at the ends of table rows. Foswiki:Tasks/Item10388: broke out JEditable into a separate package
13161 2.0.2 (2 Feb 2011) Bulletproofed against issues with rows that are shorter or longer than the format. Foswiki:Tasks/Item2016: doesn't save "0" in table cells; fixed.Foswiki:Tasks/Item2229: needs better headings support; fixed. Foswiki:Tasks/Item1186: textarea newlines are not saved with whitespace around br; fixed. Foswiki:Tasks/Item9091: orientrowedit=vertical does not show the header labels; fixed. Foswiki:Tasks/Item9775: missing section headings from Config.spec; fixed.
13159 2.0.1 (24 Feb 2009) Fixed issue with short rows, and added perms check. Thanks also to Foswikitask:Item1139TWiki:Main.MichaelDaum: fixed restoration of labels after an edit for more fixes and testing. Now works on IE. Foswikitask:Item1140: fixed loading of multi-valued parameters
13148 2.0.0 (15 Feb 2009) TWikibug:Item3770 Foswikitask:Item451 : Bugfixes ported to foswiki Foswikitask:Item5757: not respecting footer rows when saving Foswikitask:Item5681: help not fully rendered before inclusion in a TML table Foswikitask:Item1086: Macros were being expanded before editing Foswikitask:Item5924: refactor for reusability
Dependencies: Earlier version history can be found in the Subversion repository
NameVersionDescription
Foswiki::Contrib::BehaviourContrib>=0Javascript module
Foswiki::Contrib::JSCalendarContrib>=14754Javascript calendar module
Home Dependencies: Page: http://foswiki.org/cgi-bin/view/Extensions/EditRowPlugin
NameVersionDescription
Foswiki::Contrib::JSCalendarContrib>0Javascript calendar module
Foswiki::Plugins::JQueryPlugin>=4.00JQuery
Foswiki::Contrib::JEditableContrib>0Required, JQuery plugin
ONLYIF(eval('require Foswiki::Tables::Table'))
Foswiki::Contrib::TablesContrib>0Required for Foswiki < 1.2.0
Home Page: http://foswiki.org/Extensions/EditRowPlugin
IAttachmentActionSizeDateWhoComment
TableSort.jsjsTableSort.jsmanage 4.0 K 13 Nov 2013 - 11:55AdminUser  
TableSort_src.jsjsTableSort_src.jsmanage 11.0 K 13 Nov 2013 - 11:55AdminUser  
erp.jsjserp.jsmanage 10.9 K 13 Nov 2013 - 11:55AdminUser  
erp_src.jsjserp_src.jsmanage 22.5 K 13 Nov 2013 - 11:55AdminUser  
wikiringlogo20x20.pngpngwikiringlogo20x20.pngmanage 1.3 K 13 Nov 2013 - 11:55AdminUser  

Revision r2 - 29 Nov 2013 - 13:24 - AdminUser
Revision r1 - 29 Nov 2013 - 13:24 - UnknownUser
This site is powered by FoswikiCopyright © by the contributing authors. All material on this site is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback