iamyuu / gridjs-svelte

A Svelte wrapper component for Grid.js
https://npm.im/gridjs-svelte
MIT License
57 stars 13 forks source link

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

Closed atresnjo closed 2 years ago

atresnjo commented 3 years ago

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

Thanks! :)

iamyuu commented 3 years ago

"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 commented 3 years ago

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 commented 3 years ago

+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 commented 2 years ago

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 commented 2 years ago

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