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.
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.
| Prop | Type | Required | Description |
|---|---|---|---|
collection | SimulationCollection | null | Yes | The simulation collection to display |
columns | ColumnDef<Simulation>[] | No | Custom column definitions |
hideColumns | string[] | No | Array of column keys to hide |
filters | FilterDef[] | No | Custom filter definitions |
defaultFilters | Record<string, any> | No | Additional filters (merged with simulation_mode) |
initialOrderBy | string | No | Initial sort order (default: -id) |
pageSize | number | No | Items per page (default: 20) |
onRowClick | (row: Simulation) => void | No | Callback when a row is clicked |
Differences from SimulationTable
- Pre-filtered to templates:
simulation_mode=templateis automatically applied - No Activity filter: Time-based filters are not shown (templates are not time-bound)
- No mode filter: The simulation_mode filter is hidden from the UI
- 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']}
/>
Related Components
- SimulationTable - Base table with all simulations
- ServicesTable - Table for real operation simulations only
- SGERPTable - Base table component