Grid fields

The grid field type displays and maintain tables of data which are held internally as a block of JSON using the standard table format. This is different from the table field type which maintains tables of data in which each row on the table represents a node.

You can think of the grid field type as a specialised text block which holds a table. In browse mode, the table is shown like any other table in Metrici. In edit mode, the table can be edited in a grid. Interally, the table is stored as JSON.

Adding grids to generated fields

As well as using the grid field type, you can add grid functionality to script-generated content using the following methods:

  • Output a textarea with a class of "grid".
  • Initialise the textarea with the table, following the table format.
  • Optionally, include a data-options attribute with a block of JSON options. Supported options are:
    • modifyColumns - set to true to allow the user to insert, delete, rename and move columns.

If modify columns is not set, the data in the table will conform to the original columns.

If modify columns is set, the columns in the table are overwritten with simple columns that may contain any data.

Grid fields support text, number, boolean, date and timestamp columns. Other columns are treated as text.

Grid fields also support a values property for a column. This gives a list of permissible values, which will be used to create a drop-down list of values.