Subtables in Wonderful Relations

Subtables are a powerful way to represent 1-n relationships in your data. Each row in the main table can have a corresponding subtable that displays related data, offering a detailed view of the associated entries.

Key Features of Subtables:

  1. Per Row Rendering:

Subtables are rendered on a per-row basis, showing data related to the main table entry. This allows you to display hierarchical or relational data in a structured and user-friendly way.

  1. Interactive Elements:

Subtables support interactive features such as buttons, links, and other UI components, similar to main DataTables, providing seamless functionality.

  1. DataTable Features:

Subtables come with the same capabilities as main DataTables, including pagination, sorting, and filtering.

  1. Server-Side Processing:

To ensure performance, only the subtable data for the rows in the current pagination selection are processed and loaded. This minimizes resource usage and optimizes response times.

Search in Subtables

Searching in subtables is optional and configurable:

• When enabled, the main DataTable search will include subtable entries in its results.

• If a match is found in a subtable (e.g., an employee name in a location subtable), the entire subtable for that main table row is displayed.

Performance Consideration:

While subtable search can provide powerful results, it requires joining large amounts of data in some cases, which can be resource-intensive. This should be considered for datasets with tens of thousands of entries.

Parameters for Subtables

  1. Subtable:

The subtable itself is a fully functional Wonderful Relations DataTable, inheriting all features like filtering, pagination, and interactive elements.

  1. Title:

Each subtable can be assigned a title to clearly represent its purpose or the type of data it contains.

  1. Sort Order:

Subtables respect configurable sort orders, allowing you to determine how the data is displayed within the subtable.

Example Use Case

A Projects Table with subtables for associated team members:

• Each project (row in the main table) displays a subtable listing all team members, their roles, and contributions.

• Subtables include action buttons (e.g., “Edit” or “Remove”) for managing team members directly within the subtable.

• The main table’s search can optionally include subtable entries (e.g., searching for a team member’s name highlights the related project and displays the subtable).

Subtables offer a robust and visually intuitive way to handle relational data, ensuring both usability and performance.