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

Question on highlighting with nested props #116

Open
paulocr opened this issue Aug 7, 2024 · 1 comment
Open

Question on highlighting with nested props #116

paulocr opened this issue Aug 7, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request V2
Milestone

Comments

@paulocr
Copy link

paulocr commented Aug 7, 2024

Hello,

Thanks for your great library!
I have a question when using filters and nested props.

I am using data from GraphQL so every row data is wrapped in a node object like this:

    "node": {
            "id": 6,
            "name": "Customer 123",
            "customerNo": 8,
            "active": true,
    },
    ...

I am using a structure similar to your Hello World example trying to leverage my own version of the THFilter component.

{#each table.rows as row}
	{@const {
		name,
		customerNo
	} = row.node}
	<tr class="border shadow-xl m-2 w-full">
		<td>{@html customerNo}</td>
		<td>{@html name}</td>
	</tr>
{/each}

and

<ThFilter {table} field="customerNo" />
<ThFilter {table} field="name" />

in ThFilter.svelte I am setting up the filter like this:

let filter: any = table.createFilter((row) => row['node'][field] );

Filtering works but the highlight does not kick in, I assume the node object wrapper messes things up but I am curious if you have any ideas.

I am using the runes version and Svelte 5 by the way.

Thanks!

@paulocr paulocr changed the title Question for highlighting with nested props Question on highlighting with nested props Aug 7, 2024
@vincjo
Copy link
Owner

vincjo commented Aug 10, 2024

Hello,
Currently it works with litteral paths such as row.node.customerNo or row['node']['customerNo']
I parse the callback with a string convesion + regex to retrieve the path of the nested value to highlight. In your example, it returns "row['node'][field]" instead of "row['node']['customerNo']"

Highlighting is still experimental, and this is a good example of limitation.

I'm going to work on it.

@vincjo vincjo added V2 enhancement New feature or request labels Aug 10, 2024
@vincjo vincjo added this to the 2.0 milestone Aug 10, 2024
@vincjo vincjo self-assigned this Aug 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request V2
Projects
None yet
Development

No branches or pull requests

2 participants