v-data-table コンポーネントは表形式のデータを表示するために使われます。ソート、検索、ページネーション、インライン編集、ヘッダーツールチップ、行の選択 などの機能を含んでいます。

Usage

The standard data-table will by default render your data as simple rows.

API

Examples

選択可能な行

The show-select prop will render a checkbox in the default header to toggle all rows, and a checkbox for each default row. You can customize these with the slots header.data-table-select and item.data-table-select respectively. You can also switch between allowing multiple selected rows at the same time or just one with the single-select prop.

Grouped rows

Using the group-by and group-desc props you can group rows on an item property. The show-group-by prop will show a group button in the default header.

Sort on multiple columns

Using the multi-sort prop will enable you to sort on multiple columns at the same time. When enabled, you can pass arrays to both sort-by and sort-desc to programmatically control the sorting, instead of single values.

no-results スロットを使用した検索

Data table ではデータをフィルタリングするために search prop が用意されています

ヘッダー無しテーブル

hide-headers prop を設定するとヘッダーなしのテーブルを作成することができます。

Loading state

You can use the loading prop to indicate that data in the table is currently loading. If there is no data in the table, a loading message will also be displayed. This message can be customized using the loading-text prop or the loading slot.

Dense

Using the dense prop you are able to give your data tables an alternate style.

Slots

The v-data-table provides a large number of slots for customizing the table. This example showcases some of these slots and what you can do with each. It is important to note some slot (eg: item/body/header) will completely takes over the internal rendering of the component which will require you to re-implement functionalities such as selection and expansion. Some slots will override each other such as: body > item > item.<name> and header/header.<name>.

スロット: expand

The show-expand prop will render an expand icon on each default row. You can customize this with the item.data-table-expand slot. You can also switch between allowing multiple expanded rows at the same time or just one with the single-expand prop. The expanded rows are available on the synced prop expanded.sync

Custom filtering

You can override the default filtering used with search prop by supplying a function to the custom-filter prop. If you need to customize the filtering of a specific column, you can supply a function to the filter property on header items. The signature is (value: any, search: string | null, item: any) => boolean. This function will always be run even if search prop has not been provided. Thus you need to make sure to exit early with a value of true if filter should not be applied.

Customizing default header

You can use the dynamic slots header.<name> to customize only certain columns. <name> is the name of the value property in the corresponding header item sent to headers.

Customizing default rows

You can use the dynamic slots item.<name> to customize only certain columns. <name> is the name of the value property in the corresponding header item sent to headers. So to customize the calories column we're using the item.calories slot.

外部ページネーション

pagination prop を使用することで外部からページネーションを制御できます。 使用するには .sync modifier を適用する必要があります。

外部ソート

pagination prop を使用することで外部からソートも制御できます。 使用するには .sync modifier を適用する必要があります。 prop でデフォルトでソートに使用するカラムを設定することもできます。

サーバーサイドでのページネーションとソート

If you're loading data already paginated and sorted from a backend, you can use the server-items-length prop. Defining this prop will disable the built-in sorting and pagination, and you will instead need to use the available events (update:page, update:sortBy, update:options, etc) to know when to request new pages from your backend. Use the loading prop to display a progress bar while fetching data.

インライン編集

v-edit-dialog コンポーネントは Data table 内部でインライン編集する際に使用します。

CRUD アクション

各行を編集するために v-dialog コンポーネントを使用した、CRUD アクション付き Data table のサンプルです。

Edit this page on Github | Translate on Crowdin
Vuetify
StoreFor Enterprise