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

[Feature Request] Disable v-data-table sorting through a reimplementation of the disable-sort prop #19197

Closed
cojohnson1999 opened this issue Feb 8, 2024 · 2 comments · Fixed by #19820 · 4 remaining pull requests
Closed

[Feature Request] Disable v-data-table sorting through a reimplementation of the disable-sort prop #19197

cojohnson1999 opened this issue Feb 8, 2024 · 2 comments · Fixed by #19820 · 4 remaining pull requests
Assignees
Labels
C: VDataTable VDatatable T: enhancement Functionality that enhances existing features

Comments

@cojohnson1999
Copy link

cojohnson1999 commented Feb 8, 2024

Problem to solve

In Vuetify 3, v-data-table doesn't contain an easy way to prevent sorting on columns based on the value of a prop, much like how the disable-sort prop worked in Vuetify 2.

In Vuetify 2, I was able to disable sorting when a data table was loading data by adding the :disable-sort="loading" prop to my table. That allowed me to only allow sorting if we weren't loading in content, which could prevent any race conditions that led to an incorrect ordering of data due to multiple requests for data at once.

I could prevent users from sorting things by exiting early from a sort function if my loading flag is true. However, the issue is that users are still able to spam click the sort icons, and being able to prevent them from doing that by disabling those icons while data is loading would be preferable.

Proposed solution

Reimplement Vuetify 2's disable-sort prop or something similar for v-data-table and v-data-table-server. That prop should completely disable the sorting icons in the data table header so that users aren't allowed to spam click the sort buttons while data is loading or other things are happening with a table.

<v-data-table
  :loading="loading"
  :items="items"
  :disable-sort="loading"
/>
@websitevirtuoso
Copy link
Contributor

This is not wrong. each column has own prop to disable sorting.
you can use this props to disable flag, while data loading

@cojohnson1999
Copy link
Author

I believe you're talking about the sortable prop, right? While I do think it's helpful, seems like removing disable-sort adds a lot of hassle to table usability for something that could be a prop set once directly on the table. Adding a dynamic sortable field to each data table header in the application I'm working on, especially since some of those are common headers defined in a TS file for multiple tables, adds a lot of logic that feels unnecessary to me.

Are there any documented examples of dynamically setting the sortable prop on a set of table headers? I tried that and had some reactivity issues, but I may have been doing something wrong there.

@KaelWD KaelWD added T: enhancement Functionality that enhances existing features C: VDataTable VDatatable labels May 13, 2024
@MajesticPotatoe MajesticPotatoe self-assigned this May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment