Settings and REST calls of a CRUD table (CrudTableModelFactory).

The default REST calls use fetch:

  • {id} in a URL is replaced by the URL-encoded id (/api/items/{id} → /api/items/a%2Fb);
  • requests with a body (updateItem, createItem) send JSON with Content-Type: application/json (unless getHeadersInit() already sets a Content-Type);
  • the promise is rejected for an HTTP error status (4xx/5xx) and when no URL is configured; an empty response body (e.g. 204 No Content) resolves with undefined.

Every call can be replaced, e.g. to use your own HTTP client.

Example

const crudOptions: CrudOptions = {
...new CrudOptions(),
urls: {
list: new UrlInfo('GET', '/api/customers'),
read: new UrlInfo('GET', '/api/customers/{id}'),
update: new UrlInfo('PUT', '/api/customers/{id}'),
create: new UrlInfo('POST', '/api/customers'),
delete: new UrlInfo('DELETE', '/api/customers/{id}'),
},
getHeadersInit: () => ({ Authorization: 'Bearer my-token' }),
getIdKey: () => 'customerId',
getEmptyItem: () => ({ name: '', vip: false, credit: 0 }),
};

Hierarchy

  • CrudOptions

Implements

Constructors

Properties

autoAddActionColumn: boolean = true
calcFixedRightColumnCount: ((columnCount) => number) = ...

Type declaration

    • (columnCount): number
    • Parameters

      • columnCount: number

      Returns number

columnWidths: ColumnWidthsIf = ...
getEmptyItem: (() => any) = ...

Type declaration

    • (): any
    • Returns any

getHeadersInit: (() => HeadersInit) = ...

Type declaration

    • (): HeadersInit
    • Returns HeadersInit

getIdKey: (() => string) = ...

Type declaration

    • (): string
    • The property that holds the id of an item (default 'id').

      Returns string

singleRowActions: CrudAction[] = ...
tableActions: CrudAction[] = ...
urls: UrlsIf = ...

Methods