Skip to end of metadata
Go to start of metadata

Table of contents

Using the HelperList class

This Helper is used to generate a table of elements. The elements can belong to ObjectModel-type objects, but they do not have to. Example: client list, order status list.

List declaration

Fields inside [brackets] are optional as per the HTML standard.
Values between {curly braces} list the possible values for this field.

Basic declaration

Removing all the optional fields, this is how to build a basic HelperList element:

This specific code generates this list:

Enabling specific features

Sortable header

By default, the list's header simply displays the name of each column.

In order to make the column sortable and searchable, you only have to disable one option:

By disabling the simple_header option, the list displays a more complex header:

Adding an "Actions" column

The above example directly builds a table with an action column, which comprises three actions: edit, delete, view.

Note that they will not work out of the box: while the action icons are there and can be clicked, nothing will happen when the user clicks until you have assigned proper code to these actions.

Adding a "Details" row action

Principle

You can define a "Details" action (or "+" action) in each row of a list. This action is useful if you want to show other information about the row (for example, the details of a sum).

This action is represented by a "+" if the details is shown and by a "-" if the details is hidden. The content is obtained through an Ajax request.

Example

There are two possible ways to displays:

  • The easy one is to re-use the table structure. See for instance the "Stock instant state" page, under the "Stock" menu (when the "Advanced Stock Management" option is enabled).
  • You can define your own structure (for example, to display a new table within the table). See for instance the "Stock Management" page, under the "Stock" menu (when the "Advanced Stock Management" option is enabled).

Add the action

To add the "Details" action, use the following function in the target AdminController:

Ajax generalities

Ajax requests must be generated by the ajaxProcess()method in your AdminController.

Only one element is sent to the request: the table row's id. You can get it by using:

This id is defined either in the $identifier class attribute, or by the table name ($table attribute), prefixed by "id_".

This function must display the result in JSON format.

Performing an Ajax request on the table's structure

The expected JSON format:

Sample Ajax request code:

Performing an Ajax request using your own structure

The expected JSON format:

  • No labels