vanilla js implementation | No Framework #4928
Replies: 4 comments 25 replies
-
Did you ever figure this out? Running into the same issue now. |
Beta Was this translation helpful? Give feedback.
-
For those landing here you need to have a proper
The should solve the exception you getting in the Then when doing the actual rendering, you need to do this: First you need a
Then it is used like this when rendering the table
|
Beta Was this translation helpful? Give feedback.
-
I couldn't even figure out how to import the library, would love a full example. Trying to get this working in a simple html template for now. Ultimately in an ASP.NET Razor Pages project |
Beta Was this translation helpful? Give feedback.
-
+1 for vanilla examples |
Beta Was this translation helpful? Give feedback.
-
Is there an existing example of implementing table using the @tanstack/table-core.
At the moment docs only have:
`import { createTable } from '@tanstack/table-core'
const table = createTable(options)`
I tried to implement like so:
` const columnHelper = createColumnHelper();
const columns = [
columnHelper.accessor("firstName", {
cell: (info) => info.getValue(),
footer: (info) => info.column.id,
}),
columnHelper.accessor((row) => row.lastName, {
id: "lastName",
cell: (info) => {info.getValue()},
header: () => Last Name,
footer: (info) => info.column.id,
}),
columnHelper.accessor("age", {
header: () => "Age",
cell: (info) => info.renderValue(),
footer: (info) => info.column.id,
}),
columnHelper.accessor("visits", {
header: () => Visits,
footer: (info) => info.column.id,
}),
columnHelper.accessor("status", {
header: "Status",
footer: (info) => info.column.id,
}),
columnHelper.accessor("progress", {
header: "Profile Progress",
footer: (info) => info.column.id,
}),
];
const data: Person[] = [
{
firstName: "tanner",
lastName: "linsley",
age: 24,
visits: 100,
status: "In Relationship",
progress: 50,
},
{
firstName: "tandy",
lastName: "miller",
age: 40,
visits: 40,
status: "Single",
progress: 80,
},
{
firstName: "joe",
lastName: "dirte",
age: 45,
visits: 20,
status: "Complicated",
progress: 10,
},
];
const table = createTable({
columns,
data,
getCoreRowModel: getCoreRowModel(),
state: {}, // Provide the state property here
onStateChange: () => {}, // Provide the onStateChange property here
renderFallbackValue: () => null, // Provide the renderFallbackValue property here
});`
<table> <thead> { table?.getHeaderGroups()?.map((headerGroup) => ( <tr key={headerGroup.id}> {headerGroup?.headers?.map((header) => ( <th key={header.id}> hello {/* {header.isPlaceholder ? null : flexRender( header.column.columnDef.header, header.getContext() )} */} </th> )) } </tr> )) } hello </thead> <tbody> {table?.getRowModel()?.rows?.map((row) => ( <tr key={row.id}> {row.getVisibleCells().map((cell) => { const value = cell?.value; console.log("VALUEEEEE:", value); return <td key={cell.id}>hello</td>; return ( <td key={cell.id}> {/* {flexRender(cell.column.columnDef.cell, cell.getContext())} */} </td> ); })} </tr> ))} </tbody> </table>
Beta Was this translation helpful? Give feedback.
All reactions