diff --git a/packages/api-generator/src/locale/en/VDataTable.json b/packages/api-generator/src/locale/en/VDataTable.json index df73bcca2a8..278520e2fe9 100644 --- a/packages/api-generator/src/locale/en/VDataTable.json +++ b/packages/api-generator/src/locale/en/VDataTable.json @@ -18,6 +18,7 @@ "headers": "An array of objects that each describe a header column. See the example below for a definition of all properties.", "headersLength": "Can be used in combination with `hide-default-header` to specify the number of columns in the table to allow expansion rows and loading bar to function properly.", "height": "Set an explicit height of table.", + "hideDefaultBody": "Hides the default body.", "hideDefaultHeader": "Hides the default header.", "hideDefaultFooter": "Hides the default footer. This has no effect on `v-data-table-virtual`.", "hover": "Adds a hover effects to a table rows.", diff --git a/packages/vuetify/src/components/VDataTable/VDataTable.tsx b/packages/vuetify/src/components/VDataTable/VDataTable.tsx index 36ff04e6f59..830538b1acb 100644 --- a/packages/vuetify/src/components/VDataTable/VDataTable.tsx +++ b/packages/vuetify/src/components/VDataTable/VDataTable.tsx @@ -73,6 +73,7 @@ export type VDataTableSlots = VDataTableRowsSlots & VDataTableHeadersSlots export const makeDataTableProps = propsFactory({ ...makeVDataTableRowsProps(), + hideDefaultBody: Boolean, hideDefaultFooter: Boolean, hideDefaultHeader: Boolean, width: [String, Number], @@ -251,18 +252,20 @@ export const VDataTable = genericComponent( )} { slots.thead?.(slotProps.value) } - - { slots['body.prepend']?.(slotProps.value) } - { slots.body ? slots.body(slotProps.value) : ( - - )} - { slots['body.append']?.(slotProps.value) } - + { !props.hideDefaultBody && ( + + { slots['body.prepend']?.(slotProps.value) } + { slots.body ? slots.body(slotProps.value) : ( + + )} + { slots['body.append']?.(slotProps.value) } + + )} { slots.tbody?.(slotProps.value) } { slots.tfoot?.(slotProps.value) } diff --git a/packages/vuetify/src/components/VDataTable/VDataTableServer.tsx b/packages/vuetify/src/components/VDataTable/VDataTableServer.tsx index 72e3496f213..f3e9c5293aa 100644 --- a/packages/vuetify/src/components/VDataTable/VDataTableServer.tsx +++ b/packages/vuetify/src/components/VDataTable/VDataTableServer.tsx @@ -175,18 +175,20 @@ export const VDataTableServer = genericComponent )} { slots.thead?.(slotProps.value) } - - { slots['body.prepend']?.(slotProps.value) } - { slots.body ? slots.body(slotProps.value) : ( - - )} - { slots['body.append']?.(slotProps.value) } - + { !props.hideDefaultBody && ( + + { slots['body.prepend']?.(slotProps.value) } + { slots.body ? slots.body(slotProps.value) : ( + + )} + { slots['body.append']?.(slotProps.value) } + + )} { slots.tbody?.(slotProps.value) } { slots.tfoot?.(slotProps.value) } diff --git a/packages/vuetify/src/components/VDataTable/VDataTableVirtual.tsx b/packages/vuetify/src/components/VDataTable/VDataTableVirtual.tsx index ee4364ccf21..a4af3896992 100644 --- a/packages/vuetify/src/components/VDataTable/VDataTableVirtual.tsx +++ b/packages/vuetify/src/components/VDataTable/VDataTableVirtual.tsx @@ -212,48 +212,50 @@ export const VDataTableVirtual = genericComponent )} - - - - + { !props.hideDefaultBody && ( + + + + - { slots['body.prepend']?.(slotProps.value) } + { slots['body.prepend']?.(slotProps.value) } - - {{ - ...slots, - item: itemSlotProps => ( - handleItemResize(itemSlotProps.internalItem.index, height) } - > - { ({ itemRef }) => ( - slots.item?.({ ...itemSlotProps, itemRef }) ?? ( - - ) - )} - - ), - }} - + + {{ + ...slots, + item: itemSlotProps => ( + handleItemResize(itemSlotProps.internalItem.index, height) } + > + { ({ itemRef }) => ( + slots.item?.({ ...itemSlotProps, itemRef }) ?? ( + + ) + )} + + ), + }} + - { slots['body.append']?.(slotProps.value) } + { slots['body.append']?.(slotProps.value) } - - - - + + + + + )} ),