onSelectDataTable

API reference for the onSelectDataTable method.

Registers a callback that runs when a data consumer requests data from an app.

To learn more, see Creating data providers.

import { onSelectDataTable } from "@canva/preview/data";
onSelectDataTable((options) => {
options.selectDataTable({
name: "Pokemon",
columns: [
{
type: "string",
name: "Name",
values: ["Pikachu", "Squirtle", "Bulbasaur", "Charmander"],
},
{
type: "string",
name: "Type",
values: ["Electric", "Water", "Grass", "Fire"],
},
{
type: "number",
name: "Level",
values: [42, 29, 32, 9],
},
{
type: "boolean",
name: "isCaptured",
values: [true, true, false, true],
},
{
type: "date",
name: "capturedAt",
values: [new Date(), new Date(), undefined, new Date()],
},
],
});
});
#callbackfunction
Required

The callback that runs when a data consumer requests data from an app.

#callback(options)object
Required

The options that Canva passes into the callback function.

#callback(options.selectDataTable)function
Required

Sends a data table to the data consumer.

#callback(options.selectDataTable(dataTable))object
Required

The data table to send to the data consumer.

void