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

I'd like to have access to a row value for a renderComponent #105

Open
ghostwalkerj opened this issue Aug 8, 2022 · 4 comments
Open

I'd like to have access to a row value for a renderComponent #105

ghostwalkerj opened this issue Aug 8, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@ghostwalkerj
Copy link

Maybe I am looking at this the wrong way. I am using a simple 3rd party component, StarRating. The component has a required prop for rating, which is a number from 0-5 and produces stars representing the rating.

I want each row to display ratings this way as so:
screenshot_293

The only way I can think to pass the row value to this component, is to create an intermediary one, which takes the row and calls the component.

<script lang="ts">
	import StarRating from 'svelte-star-rating';
	export let row;
</script>

<StarRating rating={row.rating} />

Then call this intermediary as my renderComponent:

renderComponent: {
component: TableRating
}

This works, but seems like a waste to create a component just to parse the value of the row. Is there a better way to do this?

@dasDaniel
Copy link
Owner

dasDaniel commented Aug 8, 2022

@ghostwalkerj
Copy link
Author

That's how I built my example, and it works. But if I could have access to the specific values in the row, then I wouldn't need to build a component which is pulling out the value and sending it to the StarRating component.

I.e, if I can call it directly such as:

renderComponent: {
component: TableRating
props: {  rating : (v: row) => v.rating } } }
}

Or can you see another way I could call the component without creating a new one?

Thanks.

@dasDaniel
Copy link
Owner

dasDaniel commented Aug 8, 2022

oh, gotcha

No, not possible right now. The props would have to be transformed.

I suppose the feature could be added to pass the result of a function instead of the pre-determined values. But I'm not planning to add at the moment.

If I were to add, it would likely be replacing existing implementation instead of adding, which would cause some breaking changes

@ghostwalkerj
Copy link
Author

Fair enough. I just wanted to get my wish list in. Thanks for the project, I'm enjoying using it.

@dasDaniel dasDaniel added the enhancement New feature or request label Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants