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

Allow to use a sorting Function #414

Closed
wants to merge 1 commit into from
Closed

Conversation

arkhaiel
Copy link

Related to #399

My initial problem was the sorting process in the component was applied to the portion of data passed to the component, and not to the whole dataset.
In my own project, I managed to fix this by the updates in the PR, associated to a function I wrote in the parent component :

const sortingFunction = (column, direction) => {
  return data.value.toSorted((a,b) => {
    if(direction === 'asc'){
      return (a[column] - b[column])
    } else if(direction === 'desc') {
      return (b[column] - a[column])
    }}).slice((page.value - 1)*pageCount.value, (page.value)*pageCount.value)
}

There's one problem I can't fix : the computed property used to paginate the table is redundant with the last line of my sortingFunction, which artificially recreates the processing applied by the computed property.
I don't know if it's a huge problem or not.

@vercel
Copy link

vercel bot commented Jul 14, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
ui ❌ Failed (Inspect) Jul 14, 2023 8:13pm

@wvffle
Copy link

wvffle commented Jul 15, 2023

What if one wants to fetch sorted data from the API? Can the sorting function be async?

@arkhaiel
Copy link
Author

I know you can use aync without await !

@arkhaiel
Copy link
Author

arkhaiel commented Oct 3, 2023

Hi, I just remembered this PR.
I'm not very experienced in PR and using git with other people / branches, so I don't know what I should do to fix the conflicts ? :/

@benjamincanac
Copy link
Member

Closing in favor of #803

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

Successfully merging this pull request may close these issues.

3 participants