eLabSDK2.Inventory.Sample.SampleViewer
Extends
Methods
registerTab()
staticregisterTab(tab):void
Register a custom tab for the sample viewer modal.
The sample viewer is the read-only modal opened with eLabSDK2.Inventory.sampleViewer(). It can
open on any page, for a sample other than the one the page shows, and several viewers can be
open on top of each other. Register the tab once, when the add-on starts. Each viewer calls
load for the sample it shows when the tab is opened, keeps the result to itself and drops it
when it closes or moves to another sample. A tab with an ID that already exists is replaced.
A 'table' tab returns one page of rows from load; the viewer does the paging and calls load
again for another page. A 'custom' tab returns an HTML string. When load rejects, the viewer
shows that the tab could not be loaded.
Parameters
| Parameter | Type | Description |
|---|---|---|
tab | SampleViewerTabRegistration | {id: string, title: string, type: 'table' | 'custom', columns: SDKTableColumn[], empty: SDKTableEmptyConfig, isVisible?: (sample) => boolean, load: (sample, paging) => Promise<{ data, totalRecords }> | string | Promise<string>} |
Returns
void
Examples
// A table tab that lists items related to the sample the viewer shows
eLabSDK2.Inventory.Sample.SampleViewer.registerTab({
id: 'related-items',
title: 'Related items',
type: 'table',
columns: [{ name: 'name', displayName: 'Name' }],
empty: { iconClassName: 'fa-vial', text: 'No related items' },
isVisible: (sample) => !sample.archived,
load: async (sample, { page, records }) => {
const result = await fetchRelatedItems(sample.sampleID, page, records);
return { data: result.data, totalRecords: result.totalRecords };
}
});// A custom HTML tab
eLabSDK2.Inventory.Sample.SampleViewer.registerTab({
id: 'storage-advice',
title: 'Storage advice',
type: 'custom',
load: (sample) => `<p>Keep ${escapeHtml(sample.name)} at -80 °C.</p>`
});© 2026 eLabNext
Updated about 7 hours ago