File tree Expand file tree Collapse file tree 6 files changed +13
-7
lines changed
api-generator/src/locale/en
vuetify/src/components/VDataTable Expand file tree Collapse file tree 6 files changed +13
-7
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"props" : {
3
- "disableSort" : " Toggles rendering of sort button." ,
4
3
"everyItem" : " Indicates if all items in table are selected." ,
5
4
"headers" : " Array of header items to display." ,
6
5
"mobile" : " Renders mobile view of headers." ,
Original file line number Diff line number Diff line change 1
1
{
2
2
"props" : {
3
+ "disableSort" : " Toggles rendering of sort button." ,
3
4
"sortAscIcon" : " Icon used for ascending sort button." ,
4
5
"sortDescIcon" : " Icon used for descending sort button." ,
5
6
"sticky" : " Sticks the header to the top of the table."
Original file line number Diff line number Diff line change 12
12
"column.data-table-select" : " Slot to replace the default `v-simple-checkbox` used when selecting rows." ,
13
13
"dataTableGroup" : " Slot for custom rendering of a group." ,
14
14
"data-table-select" : " Slot for custom rendering of a header cell with the select checkbox." ,
15
+ "disableSort" : " Disables sorting completely." ,
15
16
"expanded-row" : " Slot for custom rendering of an expanded row." ,
16
17
"footer.prepend" : " Adds content to the empty space in the footer." ,
17
18
"group-header" : " Slot for custom rendering of a group header." ,
Original file line number Diff line number Diff line change 9
9
"column.data-table-select" : " Slot to replace the default `v-simple-checkbox` used when selecting rows." ,
10
10
"data-table-group" : " Slot for custom rendering of a group." ,
11
11
"data-table-select" : " Slot for custom rendering of a header cell with the select checkbox." ,
12
+ "disableSort" : " Disables sorting completely." ,
12
13
"expanded-row" : " Slot for custom rendering of an expanded row." ,
13
14
"group-header" : " Slot for custom rendering of a group header." ,
14
15
"headers" : " Slot to replace the default rendering of the `<thead>` element." ,
Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ export type VDataTableHeadersSlots = {
60
60
export const makeVDataTableHeadersProps = propsFactory ( {
61
61
color : String ,
62
62
sticky : Boolean ,
63
+ disableSort : Boolean ,
63
64
multiSort : Boolean ,
64
65
sortAscIcon : {
65
66
type : IconValue ,
@@ -142,7 +143,7 @@ export const VDataTableHeaders = genericComponent<VDataTableHeadersSlots>()({
142
143
align = { column . align }
143
144
class = { [
144
145
{
145
- 'v-data-table__th--sortable' : column . sortable ,
146
+ 'v-data-table__th--sortable' : column . sortable && ! props . disableSort ,
146
147
'v-data-table__th--sorted' : isSorted ( column ) ,
147
148
'v-data-table__th--fixed' : column . fixed ,
148
149
} ,
@@ -192,7 +193,7 @@ export const VDataTableHeaders = genericComponent<VDataTableHeadersSlots>()({
192
193
return (
193
194
< div class = "v-data-table-header__content" >
194
195
< span > { column . title } </ span >
195
- { column . sortable && (
196
+ { column . sortable && ! props . disableSort && (
196
197
< VIcon
197
198
key = "icon"
198
199
class = "v-data-table-header__sort-icon"
@@ -223,7 +224,7 @@ export const VDataTableHeaders = genericComponent<VDataTableHeadersSlots>()({
223
224
const headerProps = mergeProps ( props . headerProps ?? { } ?? { } )
224
225
225
226
const displayItems = computed < ItemProps [ 'items' ] > ( ( ) => {
226
- return columns . value . filter ( column => column ?. sortable )
227
+ return columns . value . filter ( column => column ?. sortable && ! props . disableSort )
227
228
} )
228
229
229
230
const appendIcon = computed ( ( ) => {
Original file line number Diff line number Diff line change @@ -95,8 +95,11 @@ export function useSort () {
95
95
}
96
96
97
97
// TODO: abstract into project composable
98
- export function useSortedItems < T extends InternalItem > (
99
- props : { customKeySort : Record < string , DataTableCompareFunction > | undefined } ,
98
+ export function useSortedItems < T extends InternalItem > (
99
+ props : {
100
+ customKeySort : Record < string , DataTableCompareFunction > | undefined
101
+ disableSort ?: Boolean
102
+ } ,
100
103
items : Ref < T [ ] > ,
101
104
sortBy : Ref < readonly SortItem [ ] > ,
102
105
options ?: {
@@ -107,7 +110,7 @@ export function useSortedItems <T extends InternalItem> (
107
110
) {
108
111
const locale = useLocale ( )
109
112
const sortedItems = computed ( ( ) => {
110
- if ( ! sortBy . value . length ) return items . value
113
+ if ( ! sortBy . value . length || props . disableSort ) return items . value
111
114
112
115
return sortItems ( items . value , sortBy . value , locale . current . value , {
113
116
transform : options ?. transform ,
You can’t perform that action at this time.
0 commit comments