Skip to content

Commit

Permalink
feat(VDataTable): Add option to hide an entire column
Browse files Browse the repository at this point in the history
  • Loading branch information
SystemKeeper committed Jul 26, 2024
1 parent 3024bb1 commit 1bfecea
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/vuetify/src/components/VDataTable/VDataTable.sass
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
& .v-data-table-header__content
display: contents

&.v-data-table-column--hidden
display: none

> th
align-items: center

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const VDataTableColumn = defineFunctionalComponent({
width: [Number, String],
maxWidth: [Number, String],
nowrap: Boolean,
hidden: Boolean,
}, (props, { slots }) => {
const Tag = props.tag ?? 'td'
return (
Expand All @@ -29,6 +30,7 @@ export const VDataTableColumn = defineFunctionalComponent({
'v-data-table-column--last-fixed': props.lastFixed,
'v-data-table-column--no-padding': props.noPadding,
'v-data-table-column--nowrap': props.nowrap,
'v-data-table-column--hidden': props.hidden,
},
`v-data-table-column--align-${props.align}`,
]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ export const VDataTableHeaders = genericComponent<VDataTableHeadersSlots>()({
onClick={ column.sortable ? () => toggleSort(column) : undefined }
fixed={ column.fixed }
nowrap={ column.nowrap }
hidden={ column.hidden }
lastFixed={ column.lastFixed }
noPadding={ noPadding }
{ ...headerProps }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export const VDataTableRow = genericComponent<new <T>(
maxWidth={ !mobile.value ? column.maxWidth : undefined }
noPadding={ column.key === 'data-table-select' || column.key === 'data-table-expand' }
nowrap={ column.nowrap }
hidden={ column.hidden }
width={ !mobile.value ? column.width : undefined }
{ ...cellProps }
{ ...columnCellProps }
Expand Down
1 change: 1 addition & 0 deletions packages/vuetify/src/components/VDataTable/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type DataTableHeader<T = Record<string, any>> = {
minWidth?: string
maxWidth?: string
nowrap?: boolean
hidden?: boolean

headerProps?: Record<string, any>
cellProps?: HeaderCellProps
Expand Down

0 comments on commit 1bfecea

Please sign in to comment.