Templates Table

Pre-configured table for template simulations

Live Example

Templates Table (Templates Only)

Displays only template simulations (simulation_mode=template) with Project filter

This table automatically filters to show only templates. The simulation_mode filter and Activity filter are hidden since they're not relevant for templates.

Loading...

TemplatesTable

A specialized table component for displaying template simulations (simulation_mode=template). This table extends SimulationTable with a pre-applied filter for templates and hides irrelevant filters like Activity and Mode.

Usage

Basic Table

Display template simulations with automatic filtering.

import { useSGERP } from 'sgerp-frontend-lib';
import { TemplatesTable } from '@/components/sgerp/tables/templates-table';

function MyComponent() {
  const api = useSGERP();
  
  return (
    <TemplatesTable 
      collection={api?.collections.simulation ?? null}
      onRowClick={(row) => console.log('Clicked:', row)}
    />
  );
}

Features

  • Pre-filtered: Automatically shows only simulation_mode=template
  • Project Filter: Autocomplete dropdown for filtering by project
  • Simplified Interface: Hides Activity and Mode filters (not relevant for templates)
  • All SimulationTable columns: Includes all columns for comprehensive template info

Props

Same as SimulationTable. The simulation_mode filter is automatically applied via defaultFilters.

PropTypeRequiredDescription
collectionSimulationCollection | nullYesThe simulation collection to display
columnsColumnDef<Simulation>[]NoCustom column definitions
hideColumnsstring[]NoArray of column keys to hide
filtersFilterDef[]NoCustom filter definitions
defaultFiltersRecord<string, any>NoAdditional filters (merged with simulation_mode)
initialOrderBystringNoInitial sort order (default: -id)
pageSizenumberNoItems per page (default: 20)
onRowClick(row: Simulation) => voidNoCallback when a row is clicked

Differences from SimulationTable

  1. Pre-filtered to templates: simulation_mode=template is automatically applied
  2. No Activity filter: Time-based filters are not shown (templates are not time-bound)
  3. No mode filter: The simulation_mode filter is hidden from the UI
  4. Simplified for template management: Perfect for browsing and selecting templates

Examples

Project Templates

Show templates for a specific project with time-related columns hidden.

<TemplatesTable 
  collection={api?.collections.simulation ?? null}
  defaultFilters={{ project_id: 123 }}
  hideColumns={['start_time', 'end_time', 'booking_start_time', 'booking_end_time']}
  initialOrderBy="name"
/>

This shows templates for project 123, hiding time-related columns and sorting by name.

Template Selection

Use this table to let users browse and select templates for creating new simulations:

<TemplatesTable 
  collection={api?.collections.simulation ?? null}
  onRowClick={(template) => createSimulationFromTemplate(template)}
/>

Template Management

Perfect for template administration pages:

<TemplatesTable 
  collection={api?.collections.simulation ?? null}
  hideColumns={['is_operational', 'bookings_open']}
/>