Framework
A list of fifty orders has two jobs: help the operator find one order and open the right record. Choose the columns and row identifier first, then pass filtering, paging and sorting to the data source that can apply them across the whole result set.
Admin list pages usually rely on the DataGrid component from @open-mercato/ui. It pairs beautifully with the query engine to deliver fast, tenant-aware listings.
import { DataGrid } from '@open-mercato/ui/backend/DataGrid';
import { readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall';
const columns = [
{ id: 'sku', header: 'SKU', width: 140 },
{ id: 'name', header: 'Name', minWidth: 240 },
{ id: 'onHand', header: 'On hand', align: 'right' },
];
export default async function InventoryGrid() {
const data = await readApiResultOrThrow('/api/inventory/items?limit=50');
return (
<DataGrid
title="Inventory"
columns={columns}
rows={data.items}
defaultSort={[{ id: 'updated_at', dir: 'desc' }]}
canExport
/>
);
}
The query engine lets you filter by base fields, extension fields, and custom fields using a single JSON filter definition. The DataGrid exposes filters and onFiltersChange props to render filter UIs.
const filters = [
{
id: 'cf:priority',
type: 'select',
label: 'Priority',
options: [
{ label: 'High', value: 'high' },
{ label: 'Medium', value: 'medium' },
{ label: 'Low', value: 'low' },
],
},
];
On the server, map these filters to query engine constraints:
const filters = parseFilters(request); // your helper
const result = await queryEngine.query('inventory:item', {
filters,
fields: ['sku', 'name', 'cf:priority'],
page: { page, pageSize },
tenantId, // required — the engine throws without a tenant scope
organizationId,
});
// result: { items, page, pageSize, total }
Seed enough records to require a second page and choose a search term that matches a record on that page. The filtered result should find it. If only the original page is searched, inspect the parameters sent to the API before changing the grid component.
Previous: Custom field validation · Next: Extending the field registry