State Pages Deprecated
Deprecated: use Web Pages for new work State pages and UI components still run, but new pages should use Web Pages: faster, simpler and fully indexable. The migration guide shows which web block replaces what.

Iterations

On an Advanced Datatable, render custom rows with a Custom Component on the Row Component outpin. The frontend reuses that one component for every row, instead of rebuilding a component per row on the backend.

This page is for maintaining existing state pages. On a web page, a row is a template: see web_foreach and Lists.

Use iterative components when a row needs more than storage content

Our system is designed to render precisely what you request. On Advanced Datatables, content comes directly from storage by default, but sometimes that does not suffice.

Take a status label within the datatable. You could use the Row Map function and return a state pin with the corresponding name, but that rebuilds the entire component for each row on the backend and then fetches it on the frontend. Iterate states are more efficient.

Drag from Row Component and assign a Custom Component

  1. Create the block

    An Advanced Datatable has an outpin named Row Component. Dragging from it creates the execute component block.

  2. Assign your component

    Assign a Custom Component in that block. The system uses it for each row's individual column, reusing it on the frontend to enhance rendering speed.

  3. Add backend data if needed

    Backend-exclusive information can still be provided via the Map Row functionality; what it returns is accessible to your component as well.

Parameters a row component receives

ParameterExample usage
uidUnique identifier for the row
indexPosition of the item (starting from 0)
columnsArray of columns displayed in datatable
rowrow._meta.guid, row.username, row.firstname, row.lastname, row.email, row.language
Use a tr as the first item in the component Use a tr element as the first item in the row component. This ensures the component fits properly in the datatable.

Add a guid to enable the JSON right-click

To enable the JSON right-click modal for a row, add guid={row._meta.guid} as a parameter to the tr element in the row render component.

An example row component

In React, it is possible to return data without enclosing it within an HTML tag. This is highly recommended, as fewer DOM nodes lead to faster rendering.

react-iterate.jsx
const { translate } = window.RUAL;

export default function CustomComponent({ uid, index, columns, row }) {
  return (
    <tr guid={row._meta.guid}>
      <td>
        <a href={`/users/${row._meta.guid}`}>
          {row.username}
        </a>
      </td>
      <td>
        {row.firstname} {row.lastname}
      </td>
      <td>
        <a href={`mailto:${row.email}`}>
          {row.email}
        </a>
      </td>
      <td>
        {translate(row.language)}
      </td>
    </tr>
  );
}
Migrate from State Pages Move a datatable and its row components to web blocks.

Frequently asked

How do I render a custom component per row in a RUAL datatable?

Drag from the Row Component outpin of the Advanced Datatable to create an execute component block and assign your custom component to it. The frontend reuses that component for each row, which is much faster than returning a state through Row Map, because that rebuilds the entire component per row on the backend.

What data does a RUAL row component receive?

The iterate parameters uid, index, columns and row are provided automatically, and anything returned from the Map Row functionality is accessible to your component as well.

Why should a RUAL datatable row component start with a tr element?

So the component fits properly in the datatable. Add guid={row._meta.guid} to the tr element when you also want the JSON right-click modal enabled for the row.