Lookup Editor with REST
Double-click Project ID. The editor resolves Warehouse, the saved ID, even though it is outside the first page. Search for Support, select it, and choose Apply. This example uses an in-browser REST response.
Connect your endpoint
Section titled “Connect your endpoint”createLookupRestDataSource implements the Lookup Editor datasource contract over JSON. It forwards cancellation from the search and resolver, and validates item IDs, labels, and cursors.
import { LookupEditor, createLookupRestDataSource,} from '@revolist/revogrid-pro';
const dataSource = createLookupRestDataSource({ url: '/api/projects/lookup', pageSize: 25, credentials: 'same-origin',});
const column = { prop: 'projectId', name: 'Project', editor: LookupEditor, lookup: { dataSource, context: (cell) => ({ accountId: cell.model.accountId }), },};Handle two POST bodies at the endpoint.
| Mode | Input | Response |
|---|---|---|
search | query, optional cursor, pageSize, and context | { items: [{ value: 42, label: 'Warehouse' }], nextCursor: 'page-2' } |
resolve | Selected ids and context | { items: [{ value: 42, label: 'Warehouse' }] } |
Return a missing or null cursor to end paging. The resolver should return authorized IDs even when they are absent from the current query. Omit missing or inaccessible IDs. The editor preserves those selections with its unavailable-ID label. You can supply localized search, loading, retry and empty-state text through lookup.text.