Skip to content

Custom sub-view panels

A sub-view is always a generated grid or form (Type="Table" or Type="Form"). There is no Type for a custom component. You can still put a fully custom panel in a sub-view tab — a timeline, a stepper, a chart — by combining two things you already have:

  1. A single-row view. The view returns exactly one row with one visible column that holds everything the panel needs, usually as one JSON document.
  2. A host renderer. That column has Render="key", and the host app registers a React component under that key (see Custom UI functions).

The grid around the cell is then hidden with CSS, so the tab reads as one panel. Genie itself is not changed, and the panel keeps everything a view has: RBAC, @Parent__Id scoping, session parameters and the normal data endpoints.

The example below adds a Flow tab to each row of a Tasks grid, drawn as a stepper.

<Table Name="Tasks" Slug="tasks" Label="My Tasks" Icon="fa fa-list-check"
DisableActions="true" ViewAction="Disabled">
<Sql PrimaryKey="Id" SortBy="EnteredAt" SortDirection="ASC" PageSize="25">
<!-- … the task list; Id is the row the sub-view is scoped by … -->
</Sql>
<SubConfig>
<SubView Type="Table" Name="TaskFlow" Label="Flow" Icon="fa fa-diagram-project" />
</SubConfig>
</Table>

Keep the expensive work out of the parent grid. In this example the flow is computed only for the one task the user opens, instead of once per row on every page.

2. The panel view: one row, one visible cell

Section titled “2. The panel view: one row, one visible cell”
<Table Name="TaskFlow" Slug="task-flow" Label="Flow" Icon="fa fa-diagram-project"
DisableActions="true" ViewAction="Disabled">
<ParentView Name="Tasks" />
<Sql PrimaryKey="Id" SortBy="Id" SortDirection="ASC" PageSize="1">
<![CDATA[
SELECT s.[Id],
(SELECT d.[Label] AS [workflow],
(SELECT st.[Seq] AS [n], st.[Label] AS [l], st.[Status] AS [s]
FROM [Workflow].[Steps] st
WHERE st.[InstanceId] = s.[InstanceId]
ORDER BY st.[Seq]
FOR JSON PATH) AS [steps]
FOR JSON PATH, WITHOUT_ARRAY_WRAPPER, INCLUDE_NULL_VALUES) AS [FlowDetail]
FROM [Workflow].[InstanceStates] s
JOIN [Workflow].[Definitions] d ON d.[Id] = s.[DefinitionId]
WHERE s.[Id] = @Parent__Id
]]>
</Sql>
<Columns>
<Column Name="Id" Hide="true" Export="false" />
<!-- The whole tab is this cell. No Expression: it would run before the renderer and replace the value. -->
<Column Name="FlowDetail" Label="Flow" Render="flow-stepper" Export="false" />
</Columns>
</Table>

What makes this a panel rather than a grid:

Setting Why
PageSize="1" and WHERE … = @Parent__Id Exactly one row, for the parent row that was opened.
Id with Hide="true" The primary key the view needs, not shown.
One column with Render="key" The cell the renderer draws, which becomes the whole tab.
Export="false" on the payload Otherwise an export contains raw JSON.
No Expression on the payload A column Expression runs before the renderer and replaces its value.
DisableActions="true", ViewAction="Disabled" No Add, Edit, Delete or View buttons on a read-only panel.

On PostgreSQL, build the same document with json_build_object and json_agg:

SELECT s."Id",
json_build_object(
'workflow', d."Label",
'steps', (SELECT json_agg(json_build_object('n', st."Seq", 'l', st."Label", 's', st."Status")
ORDER BY st."Seq")
FROM "Workflow"."Steps" st
WHERE st."InstanceId" = s."InstanceId")
)::text AS "FlowDetail"
FROM "Workflow"."InstanceStates" s
JOIN "Workflow"."Definitions" d ON d."Id" = s."DefinitionId"
WHERE s."Id" = @Parent__Id;

3. The renderer: a React component in the host app

Section titled “3. The renderer: a React component in the host app”
src/workflow/FlowStepperCell.tsx
import type { GenieRenderContext } from "@genie/genie-engine-ui";
import { useMemo } from "react";
interface FlowStep { n: number; l: string; s: "Done" | "Current" | "Pending" | string }
interface FlowDetail { workflow: string | null; steps: FlowStep[] | null }
function parse(value: string): FlowDetail | null {
try {
return JSON.parse(value) as FlowDetail;
} catch {
return null;
}
}
export function FlowStepperCell({ ctx }: { ctx: GenieRenderContext }) {
const detail = useMemo(() => parse(ctx.value), [ctx.value]);
// Never throw: a renderer runs inside the table's render. Show the raw value instead.
if (!detail) return <>{ctx.value}</>;
if (!detail.steps?.length) return <p className="app-stepper-empty">No flow diagram.</p>;
return (
<ol className="app-stepper" aria-label={detail.workflow ?? "Flow"}>
{detail.steps.map((step) => (
<li key={step.n} className={`app-stepper-step is-${step.s.toLowerCase()}`}
aria-label={`${step.l}: ${step.s}`}>
<span className="app-stepper-marker">{step.s === "Done" ? "✓" : step.n}</span>
<span className="app-stepper-label">{step.l}</span>
</li>
))}
</ol>
);
}

Register it under the key the column uses:

src/main.tsx
import type { GenieRenderContext } from "@genie/genie-engine-ui";
import { createGenieApp } from "@genie/genie-engine-ui";
import { FlowStepperCell } from "./workflow/FlowStepperCell";
import "./styles/stepper.css";
// Module scope: createGenieApp reads the config once.
const RENDERERS = {
"flow-stepper": (ctx: GenieRenderContext) => <FlowStepperCell ctx={ctx} />,
};
const GenieApp = createGenieApp({
apiBase: "/api/v1/genie",
handlers: { renderers: RENDERERS },
});

If the tab shows raw JSON, the key in RENDERERS doesn’t match the column’s Render value.

The panel is still a one-row table, so hide its toolbar, header and cell padding. Scope the rules carefully. The sub-view renders inside an expanded row of the parent grid, so the parent’s container also contains your component. A plain .genie-table-container:has(.app-stepper) would hide the parent grid’s header too. Match only the innermost container, the one with no other table inside it, and use child (>) selectors:

src/styles/stepper.css
.genie-table-container:has(.app-stepper):not(:has(.genie-table-container)) > .genie-table-controls,
.genie-table-container:has(.app-stepper):not(:has(.genie-table-container))
> .genie-table-wrapper > .genie-table > thead {
display: none;
}
.genie-table-container:has(.app-stepper):not(:has(.genie-table-container))
> .genie-table-wrapper > .genie-table > tbody > tr > td {
padding: 0;
border: 0;
background: transparent;
}
.app-stepper { display: flex; gap: 12px; list-style: none; margin: 0; padding: 12px 0; }

Use the theme’s tokens rather than fixed colours, so the panel follows light and dark mode.

  • The parent grid has <SubView Type="Table" Name="…"> pointing at the panel view.
  • The panel view returns one row filtered by @Parent__Id, with PageSize="1".
  • One visible column has Render="key" and Export="false", and no Expression.
  • The host registers the same key in handlers.renderers.
  • The renderer never throws and shows the raw value if it can’t parse it.
  • The CSS that hides the table chrome matches only the innermost container.
  • The panel view has its own RBAC entry like any other view.