Is it possible to create dropdown in GlobalContext as shown in picture below?
It’s possible to create dropdown in GlobalContext. You can try this:
globalActions: {
selectWorksheet: {
parameters: [{
name: "spreadSheetId",
displayName: "Spreadsheet ID",
type: {
type: "choice",
options: ["option 1", "option 2"]
}
}]
},
}
Thank you for your prompt response.
Do you have any example how to pass dynamic data to the options from react component?
Ideally, you should be able to use setControlContextData
documented here to be able to set the parameter options dynamically like the below snippet.
export const HelloGlobalContext = ({ children, setControlContextData }: any) => {
setControlContextData?.({names: ["a", "b", "c"]}); // this is the main focus line
const actions = useMemo(() => ({
sayHello: (name: string) => alert("Hello, " + name),
}), []);
return (
<GlobalActionsProvider contextName="HelloGlobalContext" actions={actions}>
{children}
</GlobalActionsProvider>
);
}
PLASMIC.registerGlobalContext(HelloGlobalContext, {
// name should match GlobalActionsProvider contextName
name: "HelloGlobalContext",
props: {},
// globalActions should match the global context's GlobalActionsProvider
globalActions: {
sayHello: {
parameters: [{
name: "name",
type: {
type: "choice",
options: (_props, ctx) => {
console.log(ctx)
return ctx?.names ?? ["dummy", "data"]
}
}
}]
},
},
});
But currently, a bug in our code causes the ctx
to always be undefined. We are working on a fix.
I am trying to integrate Google Sheets into Plasmic.
Because of the dynamic of the spreadsheets, I want to be able to select spreadsheet Id from a dropdown list in plasmic studio and then its respective worksheets will appeared in the next dropdown. Once a specific worksheet, all its header rows will be shown as inputs where I can dynamically entered values.
Are they any options to achieve this since the pesky bug is withholding the setControlContextData function?
Thank you.