XWiki Livetable Checkbox Column Macro

Last modified by Thomas Mortagne on 2025/06/09 00:04

cogAdds the option to select the rows of a livetable by inserting a new column with checkboxes in the table.
TypeXAR
CategoryMacro
Developed by

Raluca Stavro

Active Installs31
Rating
0 Votes
LicenseGNU Lesser General Public License 2.1

Success

Installable with the Extension Manager

Description

Warning

This macro is relying on the fix for XWIKI-12722.
This bug was introduced in version 2.6 (long time ago) so it is very possible that you have it on your XWiki instance. The fix is very simple and you have to apply it if you need to use this macro.

This macro is adding a new column in the livetable containing checkboxes for selecting table rows. It supports the following parameters :

NameDescriptionIs MandatorySinceDefault value
livetableThe id of the livetableYes1.0N/A
columnThe target column to use the values of when selecting items in the checkbox columnYes1.0N/A
serviceDocumentThe name of the document acting as service for the selected valuesNo1.0N/A
buttonIdThe id of the element that is clicked for sending data to the service documentNo1.0N/A
titleThe title of the column that will have the checkboxesNo1.1.0N/A
urlParamsThe default URL parameters that will be sent to the serverNo1.1.0xpage=plain&outputSyntax=plain

Since 1.1.0, after the call to the service document, a JavaScript event is fired in the document. The name of the event is :

  • xwiki:livetable:${livetableId}:checkboxes:success if the call was sucessful (HTTP 200)
  • xwiki:livetable:${livetableId}:checkboxes:failure if the call failed

Example of usage

The code

{{html}}
  <div class="buttonwrapper">
    <a href="" id="checkboxService" class="button">Send checkbox data</a>
  </div>
{{/html}}

{{velocity}}
  #set($columns = ['doc.fullName', 'doc.title', 'doc.author', 'doc.date'])
  #set($columnsProperties = {
    'doc.fullName' : { 'type' : 'hidden' },
    'doc.title' : { 'displayName' : 'Title' } ,
    'doc.author' : { 'displayName' : 'Author' } ,
    'doc.date' : { 'displayName' : 'Date' }
  })
  #set($options = {
     'extraParams':'&space=XWiki',
     'queryFilters': '&hidden=true'
  })
  #livetable('myLivetable' $columns $columnsProperties $options)
{{/velocity}}

{{addCheckboxColumnToLivetable livetable="myLivetable" column="doc.fullName" buttonId="checkboxService" serviceDocument="Code.ServiceDocument" /}}

The result

1. The livetable

Selecting multiple values of the doc.fullName colum that is hidden in this example :

AddCheckboxColumnToLivetable.png

2. Sending data to the service document

The URL of the Ajax request sent by the macro :

http://localhost:8080/xwiki/bin/Code/ServiceDocument?outputSyntax=plain&xpage=plain&cbData=docsmanagement%3AXWiki.AdminEditingSheet&cbData=docsmanagement%3AXWiki.AdminElementsSheet&cbData=docsmanagement%3AXWiki.AdminGroupsSheet&cbData=docsmanagement%3AXWiki.AccountValidation&cbData=docsmanagement%3AXWiki.AdminExportSheet

Prerequisites & Installation Instructions

We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager). Note that installing Extensions when being offline is currently not supported and you'd need to use some complex manual method.

You can also use the following manual method, which is useful if this extension cannot be installed with the Extension Manager or if you're using an old version of XWiki that doesn't have the Extension Manager:

  1. Log in the wiki with a user having Administration rights
  2. Go to the Administration page and select the Import category
  3. Follow the on-screen instructions to upload the downloaded XAR
  4. Click on the uploaded XAR and follow the instructions
  5. You'll also need to install all dependent Extensions that are not already installed in your wiki

Release Notes

v1.1.0

v1.0.6

v1.0.5

v1.0.4

v1.0.3

v1.0.2

v1.0.1

v1.0

Get Connected