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

How to use the cell formatter to return a Svelte component? #2

Closed
atresnjo opened this issue Mar 24, 2021 · 5 comments
Closed

How to use the cell formatter to return a Svelte component? #2

atresnjo opened this issue Mar 24, 2021 · 5 comments

Comments

@atresnjo
Copy link

Basically something like https://gridjs.io/docs/examples/react-cells

Thanks! :)

@iamyuu
Copy link
Owner

iamyuu commented Mar 31, 2021

"Grid.js uses Preact to render the elements and that means that you can take advantage of Preact's Virtual DOM and render complex cells."

And Svelte approach is using the compiler and uses real DOM, instead of using virtual DOM. So I think, you can't use Svelte component to handle this.

But you can use html, check out my repl.

@atresnjo
Copy link
Author

Hey, thanks for the reply!

html

Works fine if you just want to return the cell itself, but not a svelte component. There must be a way to create a Svelte component on fly, pass the props and then return the built html. I'll try to play around with it, thanks so far! 👍

@benwoodward
Copy link

+1.

Would be great to be able to use a Svelte component so that changes to the site theme are automatically reflected in gridjs instances.

@vince-xopolis
Copy link

I would like to use svelte components with gridjs so that I can use bootstrap icons with my data. It would be very useful to use something like html from gridjs to do it.

@iamyuu
Copy link
Owner

iamyuu commented Jan 15, 2022

Hey there! On v2 I already added plugins to wrapping the svelte component, so now we can to svelte component to render the cell. Check out the example.

Note: (currently!) when we use plugin we not receive the data, I don't why but I think it's might bug on Grid.js

@iamyuu iamyuu closed this as completed Jan 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants