Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: TanStack Table #1189

Closed
jasonwillschiu opened this issue Jul 16, 2024 · 17 comments
Closed

Enhancement: TanStack Table #1189

jasonwillschiu opened this issue Jul 16, 2024 · 17 comments
Labels
status: help wanted This issue is tentatively accepted pending a volunteer committed to its implementation type: feature Introduction of new functionality to the application

Comments

@jasonwillschiu
Copy link

Describe the feature

See here
bryanmylee/svelte-headless-table#224

Plus shadcn/ui says it's based on Tanstack Table.

Thanks for all your hard work!
Jason

@jasonwillschiu jasonwillschiu added the type: feature Introduction of new functionality to the application label Jul 16, 2024
@huntabyte
Copy link
Owner

The last time I tried tanstack table it was a nightmare. I'll revisit the Svelte 5 rewrite and see how it goes.

@jessielaf
Copy link

@huntabyte I have been using tanstack table with Svelte for a while without any problems. Which problems did you encounter?

@robots4life
Copy link

TanStack/table#5403

@jasonwillschiu
Copy link
Author

Happy for it to be something that's not TanStack table. Just something that's maintained with similar functionality to ease my mind haha

@ESchouten
Copy link

Personally I would prefer Tanstack Table, have been using it for over a year and nothing else really comes close to it.

@shyakadavis
Copy link
Contributor

shyakadavis commented Aug 7, 2024

I'm indifferent to what ends up being used, but here is something else for consideration. (The runes-powered v2 is currently in preview)


Here's even a shadcn-svelte example:

@j13n
Copy link

j13n commented Aug 11, 2024

Just tried @tanstack/svelte-table@alpha on one of my current tables since I want to start using Svelte 5. Seems to be working fine.

You do have to have svelte@next installed though so for now it looks like:
Svelte 4 with svelte-headless-table and Svelte 5 with @tanstack/svelte-table@alpha.

If @huntabyte and the rest are cool with it I can write some documentation on how to use it. Perhaps a new section on the bottom of the current data-table docs with instructions on how to make data-tables with Svelte 5.

@robots4life
Copy link

This is just a heads up for anyone following the current docs on Data Table.

I had an issue where I wanted to combine pagination and sort with the current Data Table per docs but use a different icon for sorting the table up and down.

The solution is to include 2 unused properties, pageCount and pageSize for the Data Table to work correctly with props.sort.order.

const { hasNextPage, hasPreviousPage, pageIndex, pageCount, pageSize } = pluginStates.page;

Even though this is not mentioned in the docs because there an ArrowUpDown is used to trigger the sorting it makes sense to want to indicate to the user in what direction the table is currently sorted.

If we stick with svelte-headless-table for a while this is possibly worth mentioning in the docs.

@stefa168
Copy link
Contributor

+1 for TanStack

@huntabyte huntabyte changed the title Can we please move from svelte-headless-table to tanstack table? Since svelte-headless-table is no longer actively maintained Enhancement: TanStack Table Aug 28, 2024
@huntabyte
Copy link
Owner

After having used TanStack pretty extensively over the last few days, I can confirm that most of the issues I experienced with it the first time have been corrected.

If someone would like to update the DataTable docs and examples to use TanStack it would be greatly appreciated, otherwise, I will get to it as soon as I have the chance!

@huntabyte huntabyte added status: help wanted This issue is tentatively accepted pending a volunteer committed to its implementation status: accepted This issue has been accepted and assigned to someone for implementation. and removed status: accepted This issue has been accepted and assigned to someone for implementation. labels Aug 28, 2024
@c-kirkeby
Copy link

c-kirkeby commented Aug 28, 2024

I'll be happy to have a go. I just recently tried to do this myself and I've got a draft PR open on a personal project. My main blocker has been trying to pass children to table cells as part of the table definition, something that was possible with svelte-headless-table but does not seem straightforward with TanStack Table (at least not following their docs).

Update 2/09/2024: this issue looks like it might resolve the issue I had, will have a prod around

@c-kirkeby
Copy link

c-kirkeby commented Sep 4, 2024

Okay so rather than doubling up on trying to convert the Tasks demo (@shyakadavis has picked it up in #1260), I implemented the Data Table for my own project here at c-kirkeby/osrs-price-site#3. It doesn't have the filter or the actions / row selection or the filters from the Tasks example, and mine has some more complex use cases like colouring cells / right-aligning cells.

One issue I ran into was this:
https://github.com/c-kirkeby/osrs-price-site/pull/3/files#diff-dfcbcef4795391b3fac61ea52dc73d867264ba430a9ea6dfcab677acd7777e66R72-R73

Due to TanStack/table#4382 there are some TypeScript errors when assigning columns to the ColumnDef<TData, TValue> type.

I don't love the Svelte API for TanStack. It's a lot of React-like getters and setters, where as svelte-headless-table took much more of Svelte-like approach. They're apparently looking to improve it though. I also could not find a way to use Svelte slots with custom components in column defs (this is more for the reusable data table).

@robots4life
Copy link

It might be worth to point out that TanStack Table will not be supported by Svelte 5 out of the box.

sveltejs/svelte#10359 (comment)

#1260 (comment)

Perhaps it is a good idea to wait for TanStack Table to support Svelte 5 before writing new documentation.

@ESchouten
Copy link

@robots4life Correction: Tanstack Table v8 will not support Svelte 5, Tanstack Table v9 only supports Svelte 5 and up

@stefa168
Copy link
Contributor

stefa168 commented Oct 17, 2024

I have used Tanstack Table v9 alpha for the last two months and from what I've experienced it isn't ready for use yet.

I'd suggest waiting for the release or maybe make separate examples for both Tanstack Table and datatables

@robots4life
Copy link

Here is a guide to using Svelte 5 with TanStack Table v8 that @walker-tx put together.

https://github.com/walker-tx/svelte5-tanstack-table-examples

TanStack/table#5403 (comment)

After some of the questions on Discord and here, I've put together a reference project so folks can see how they can implement their own Svelte 5 adapter for @tanstack/table-core v8:

https://github.com/walker-tx/svelte5-tanstack-table-examples

Hopefully, this gives folks a clearer path to value.

Full disclosure: I threw this together in a caffeinated frenzy. Once I get some rest, I'll go back over everything with fresher eyes.

@huntabyte
Copy link
Owner

We're now using TanStack Table in shadcn-svelte@next - https://next.shadcn-svelte.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: help wanted This issue is tentatively accepted pending a volunteer committed to its implementation type: feature Introduction of new functionality to the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants