[]
A remote table retrieves data from a server and optionally synchronizes changes back to it.
Unlike a memory table, a remote table does not contain data until fetch() is executed.
Remote tables support:
Server-side data loading
Data synchronization (single or batch mode)
Schema mapping
Multiple response protocols
The minimum requirement for a remote table is a read configuration.
Example using the standardized products dataset:
const dataManager = spread.dataManager();
const products = dataManager.addTable("products", {
remote: {
read: {
url: "https://demodata.mescius.io/northwind/api/v1/products",
method: "GET"
}
}
});At this point, the table structure is defined but contains no records.
All tables must call fetch() before further operations.
orders.fetch();If fetch() is not called, the table remains empty.
Example:
orders.fetch().then(function () {
const view = orders.addView("orderView");
});fetch() performs:
Remote data retrieval
Schema adaptation
Internal state initialization
All remote operations depend on a completed fetch.
Remote responses may require field mapping or type conversion.
Example:
const products = dataManager.addTable("products", {
remote: {
read: {
url: "https://demodata.mescius.io/northwind/api/v1/products"
}
},
schema: {
columns: {
id: { dataName: "ProductId" },
name: { dataName: "ProductName" },
price: { dataName: "UnitPrice", dataType: "number" },
stock: { dataName: "UnitsInStock", dataType: "number" }
}
}
});Schema configuration is documented in the Schema section.
To enable data write-back, additional remote operations must be defined.
Example (single sync mode):
const products = dataManager.addTable("products", {
remote: {
read: { url: "https://example.com/api/products", method: "GET" },
create: { url: "https://example.com/api/product", method: "POST" },
update: { url: "https://example.com/api/product", method: "PUT" },
delete: { url: "https://example.com/api/product", method: "DELETE" }
},
autoSync: true
});Synchronization modes are explained in:
Remote tables support:
Standard JSON responses
REST adapter
OData
OData v4
GraphQL
Protocol configuration is documented in: