-
I try to use glide-data-grid with taipy. I have created a dynamic element, though the page is blank. Because, the grid depends on there being a root level "portal" div in your HTML. How can I add a html div element to body? |
Beta Was this translation helpful? Give feedback.
Answered by
c6p
Mar 13, 2024
Replies: 2 comments 2 replies
-
Could you share the code you have written? |
Beta Was this translation helpful? Give feedback.
0 replies
-
Skipping data passing and CSS. Modifying Element.tsx from guiext-template does not render DataEditor. import { useDynamicProperty } from "taipy-gui";
import * as React from "react";
import DataEditor, { DataEditorProps, GridCellKind, GridColumn, Item, GridCell } from "@glideapps/glide-data-grid";
const data = [
{
firstName: "John",
lastName: "Doe"
},
{
firstName: "Maria",
lastName: "Garcia"
},
{
firstName: "Nancy",
lastName: "Jones"
},
{
firstName: "James",
lastName: "Smith"
}
];
const columns: GridColumn[] = [
{ title: "First Name", width: 100 },
{ title: "Last Name", width: 100 }
];
function getData([col, row]: Item): GridCell {
const person = data[row];
if (col === 0) {
return {
kind: GridCellKind.Text,
data: person.firstName,
allowOverlay: false,
displayData: person.firstName
};
} else if (col === 1) {
return {
kind: GridCellKind.Text,
data: person.lastName,
allowOverlay: false,
displayData: person.lastName
};
} else {
throw new Error();
}
}
interface ElementProps {
text?: string;
}
export default function Element({ text }: ElementProps) {
const textProperty = useDynamicProperty(text, "<empty>", "");
if (!textProperty) {
return <span />
}
return (
<>
<span>
{textProperty.split("").reverse().join("")}
</span>
<DataEditor columns={columns} getCellContent={getData} rows={data.length} />
</>
);
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It seems the issue was related to peer dependencies of
glide-data-grid
, and not related to taipy at all. Re-installing with--legacy-peer-deps
resolved the issue.Thanks