onSelectDataTable

API reference for the onSelectDataTable method.

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

When this callback runs, an app can either:

  • Immediately send data to the consumer
  • Render a UI that allows the user to select what data to send to the consumer

To learn more, see Creating providers.

import { getDataProvider } from "@canva/data-provider";
const dataProvider = getDataProvider();
dataProvider.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

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

#callback(options)object
Required

Options that Canva passes into the callback function.

#callback(options.selectDataTable)function
Required

A method that sends a data table to a consumer. The consumer can use this data however it wants — for example, to render a chart. To learn more, see selectDataTable.

void