Datatable - Default sorting (or no sort at all) / manual sorting
See original GitHub issueIt would be nice to be able to sort / keep items in order when loading the data.
Feature
I need to display the datatable sorted DESC using a field (which is the last one in the header list). I can’t find a way to do it (maybe I’m wrong). It’s an issue especially as the API returns everything in order and Vuetify sorts everything using the first column.
I think it’s not a edge case for my project, sorting is really important and at least it would be great to be able to keep the result sorted even if we want to have sortable columns.
Implementation I’m thinking about
Having a default-sort prop in the datatable component using the name
property of the header and a direction.
<v-data-table :headers="headers" :items="results" default-sort="somefield:desc"></v-data-table>
or
<v-data-table :headers="headers" :items="results" sort-field="field" sort-desc="true"></v-data-table>
I could probably implement it if you think it’s good.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:11
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Is there a way to disable initial sorting for jquery DataTables?
Here is the solution: "aaSorting": [[ 2, 'asc' ]], 2 means table will be sorted by third column, asc in ascending order. The...
Read more >Remove default sorting of first column — DataTables forums
Hi guys,. I want to know how to remove default sorting(ordering) of first column for dataTable. Thanks in advance. Thanks,
Read more >Multi-column sorting - DataTables example
As you would expect with a desktop application, DataTables allows you to sort by multiple columns at the same time. This multiple sorting...
Read more >Data Grid - Sorting - MUI X
Sorting is enabled by default to the grid users and works out of the box without any explicit configuration. Users can set a...
Read more >Sort a Column with a Custom Order in Power BI - RADACAD
Having a reference table, that you have one value per row for EnglishEducation is perfect because then it is easier to set up...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In case it helps anyone else looking for default sorting in a data table:
Create a data-table. Use hide-actions to not show the pagination tools at the bottom and bind pagination.sync to an object in your dataset.
In your data, create a pagination key with a object. To display all rows, use the rowsPerPage value of -1.
This will sort by column2 ascending and display all items
Take a look at example 7 in the docs to see how you could do manual sorting and/or default sorting. You need to use the
pagination.sync
prop.