Data and Display
Data table filtering is a key feature that allows users to quickly find the data they are looking for.
Filtering examples
These examples demonstrate various ways that you can utilize the search prop to filter results.
Search
The data table exposes a search prop that allows you to filter your data.
Dessert (100g serving) | Calories | Fat (g) | Carbs (g) | Protein (g) | Iron (%) |
|---|---|---|---|---|---|
| Frozen Yogurt | 159 | 6 | 24 | 4 | 1 |
| Ice cream sandwich | 237 | 9 | 37 | 4.3 | 1 |
| Eclair | 262 | 16 | 23 | 6 | 7 |
| Cupcake | 305 | 3.7 | 67 | 4.3 | 8 |
| Gingerbread | 356 | 16 | 49 | 3.9 | 16 |
| Jelly bean | 375 | 0 | 94 | 0 | 0 |
| Lollipop | 392 | 0.2 | 98 | 0 | 2 |
| Honeycomb | 408 | 3.2 | 87 | 6.5 | 45 |
| Donut | 452 | 25 | 51 | 4.9 | 22 |
| KitKat | 518 | 26 | 65 | 7 | 6 |
Filter Keys
You can easily select only the column you want to filter on by using the filter-keys prop. This prop accepts an array of keys from the table items that will be used for filtering. You may also choose to disable columns from filtering by setting the filter property to false on the header item(s). In the example below the we only filter on the name column.
Name | Image | Price | Rating | Stock |
|---|---|---|---|---|
| Nebula GTX 3080 | 699.99 | In stock | ||
| Galaxy RTX 3080 | 799.99 | Out of stock | ||
| Orion RX 6800 XT | 649.99 | In stock | ||
| Vortex RTX 3090 | 1499.99 | In stock | ||
| Cosmos GTX 1660 Super | 299.99 | Out of stock |
Custom filter
You can override the default filtering used with the search prop by supplying a function to the custom-filter prop. You can see the signature of the function below.
(value: string, query: string, item?: any) => boolean | number | [number, number] | [number, number][]
Additionally, you may apply customize the filtering on a per column basis by setting custom function to the filter property on the header item(s). In the example below, the custom filter will only match inputs that are in completely in upper case.
CPU Model | Cores | Threads | Base Clock | Boost Clock | TDP (W) |
|---|---|---|---|---|---|
| Intel Core i9-11900K | 8 | 16 | 3.5 GHz | 5.3 GHz | 125W |
| AMD Ryzen 9 5950X | 16 | 32 | 3.4 GHz | 4.9 GHz | 105W |
| Intel Core i7-10700K | 8 | 16 | 3.8 GHz | 5.1 GHz | 125W |
| AMD Ryzen 5 5600X | 6 | 12 | 3.7 GHz | 4.6 GHz | 65W |
| Intel Core i5-10600K | 6 | 12 | 4.1 GHz | 4.8 GHz | 125W |
| AMD Ryzen 7 5800X | 8 | 16 | 3.8 GHz | 4.7 GHz | 105W |
| Intel Core i3-10100 | 4 | 8 | 3.6 GHz | 4.3 GHz | 65W |
| AMD Ryzen 3 3300X | 4 | 8 | 3.8 GHz | 4.3 GHz | 65W |
| Intel Pentium Gold G6400 | 2 | 4 | 4.0 GHz | 58W | |
| AMD Athlon 3000G | 2 | 4 | 3.5 GHz | 35W |
Pagination examples
Pagination is used to split up large amounts of data into smaller chunks.
External pagination
Pagination can be controlled externally by using the individual props, or by using the options prop. Remember to use v-model, so you fully control the state.
Dessert (100g serving) | Calories | Fat (g) | Carbs (g) | Protein (g) | Iron (%) |
|---|---|---|---|---|---|
| Frozen Yogurt | 159 | 6 | 24 | 4 | 1 |
| Ice cream sandwich | 237 | 9 | 37 | 4.3 | 1 |
| Eclair | 262 | 16 | 23 | 6 | 7 |
| Cupcake | 305 | 3.7 | 67 | 4.3 | 8 |
| Gingerbread | 356 | 16 | 49 | 3.9 | 16 |
Selection examples
Selection allows you to select/deselect rows and retrieve information about which rows have been selected.
Item value
For the selection feature to work, the data table must be able to differentiate each row in the data set. This is done using the item-value prop. It designates a property on the item that should contain a unique value. By default the property it looks for is id.
You can also supply a function, if for example the unique value needs to be a composite of several properties. The function receives each item as its first argument.
Operating System | Version | |
|---|---|---|
| Windows | 3.11 | |
| Windows | 95 | |
| Windows | 98 | |
| Windows | 2000 | |
| Windows | XP |
Selected values
The current selection of the data-table can be accessed through the v-model prop. The array will consist of the unique values found in the property you set using the item-value prop (or the value returned by the function you passed). You can use return-object prop if you want the array to consist of the actual objects instead.
Dessert (100g serving) | Calories | Fat (g) | Carbs (g) | Protein (g) | Iron (%) | |
|---|---|---|---|---|---|---|
| Frozen Yogurt | 159 | 6 | 24 | 4 | 1 | |
| Ice cream sandwich | 237 | 9 | 37 | 4.3 | 1 | |
| Eclair | 262 | 16 | 23 | 6 | 7 | |
| Cupcake | 305 | 3.7 | 67 | 4.3 | 8 | |
| Gingerbread | 356 | 16 | 49 | 3.9 | 16 |
[]
Selectable rows
Use the item-selectable prop to designate a property on your items that controls if the item should be selectable or not.
Dessert (100g serving) | Calories | Fat (g) | Carbs (g) | Protein (g) | Iron (%) | |
|---|---|---|---|---|---|---|
| Frozen Yogurt | 159 | 6 | 24 | 4 | 1 | |
| Ice cream sandwich | 237 | 9 | 37 | 4.3 | 1 | |
| Eclair | 262 | 16 | 23 | 6 | 7 | |
| Cupcake | 305 | 3.7 | 67 | 4.3 | 8 | |
| Gingerbread | 356 | 16 | 49 | 3.9 | 16 |
Custom select column
Use the item.data-table-select slot alongside v-checkbox-btn to customize the checkbox used for row selection. You can also use the header.data-table-select slot to customize the select-all checkbox in the header of the column.
Name | Calories | Fat | Carbs | Protein | Iron | |
|---|---|---|---|---|---|---|
| Frozen Yogurt | 159 | 6 | 24 | 4 | 1 | |
| Ice cream sandwich | 237 | 9 | 37 | 4.3 | 1 | |
| Eclair | 262 | 16 | 23 | 6 | 7 | |
| Cupcake | 305 | 3.7 | 67 | 4.3 | 8 | |
| Gingerbread | 356 | 16 | 49 | 3.9 | 16 | |
| Jelly bean | 375 | 0 | 94 | 0 | 0 | |
| Lollipop | 392 | 0.2 | 98 | 0 | 2 | |
| Honeycomb | 408 | 3.2 | 87 | 6.5 | 45 | |
| Donut | 452 | 25 | 51 | 4.9 | 22 | |
| KitKat | 518 | 26 | 65 | 7 | 6 |
Select strategies
Data-tables support three different select strategies.
| Strategy | Description |
|---|---|
'single' | Only a single row can be selected. The select all checkbox in the header is not shown |
'page' | Multiple rows can be selected. Clicking on the select all checkbox in the header selects all (selectable) rows on the current page |
'all' | Multiple rows can be selected. Clicking on the select all checkbox in the header selects all (selectable) rows in the entire data set |
Dessert (100g serving) | Calories | Fat (g) | Carbs (g) | Protein (g) | Iron (%) | |
|---|---|---|---|---|---|---|
| Frozen Yogurt | 159 | 6 | 24 | 4 | 1 | |
| Ice cream sandwich | 237 | 9 | 37 | 4.3 | 1 | |
| Eclair | 262 | 16 | 23 | 6 | 7 | |
| Cupcake | 305 | 3.7 | 67 | 4.3 | 8 | |
| Gingerbread | 356 | 16 | 49 | 3.9 | 16 | |
| Jelly bean | 375 | 0 | 94 | 0 | 0 | |
| Lollipop | 392 | 0.2 | 98 | 0 | 2 | |
| Honeycomb | 408 | 3.2 | 87 | 6.5 | 45 | |
| Donut | 452 | 25 | 51 | 4.9 | 22 | |
| KitKat | 518 | 26 | 65 | 7 | 6 |
Sorting examples
Data tables can sort rows by a column value.
Basic sorting
The sorting of your table can be controlled by the sort-by prop. This prop takes an array of objects, where each object has a key and order property, describing how the table is to be sorted.
The key corresponds to a column defined in the headers array, and order is either the string 'asc' or 'desc' indicating the order in which the items are sorted.
Unless you are using the multi-sort prop seen below, this array will almost always just have a single object in it.
Dessert (100g serving) | Calories | Fat (g) | Carbs (g) | Protein (g) | Iron (%) |
|---|---|---|---|---|---|
| Frozen Yogurt | 200 | 6 | 24 | 4 | 1% |
| Ice cream sandwich | 200 | 9 | 37 | 4.3 | 1% |
| Eclair | 300 | 16 | 23 | 6 | 7% |
| Cupcake | 300 | 3.7 | 67 | 4.3 | 8% |
| Gingerbread | 400 | 16 | 49 | 3.9 | 16% |
| Jelly bean | 400 | 0 | 94 | 0 | 0% |
| Lollipop | 400 | 0.2 | 98 | 0 | 2% |
| Honeycomb | 400 | 3.2 | 87 | 6.5 | 45% |
| Donut | 500 | 25 | 51 | 4.9 | 22% |
| KitKat | 500 | 26 | 65 | 7 | 6% |
[
{
"key": "calories",
"order": "asc"
}
]Multi sort
Using the multi-sort prop will allow user to sort on multiple columns at the same time. You can specify whether new columns should be added first or last to the sort-by array. By specifying optional modifier key, you can support both modes.
sort-by array Dessert (100g serving) | Calories 1 | Fat (g) 2 | Carbs (g) | Protein (g) | Iron (%) |
|---|---|---|---|---|---|
| Ice cream sandwich | 200 | 9 | 37 | 4.3 | 1 |
| Frozen Yogurt | 200 | 6 | 24 | 4 | 1 |
| Eclair | 300 | 16 | 23 | 6 | 7 |
| Cupcake | 300 | 3.7 | 67 | 4.3 | 8 |
| Gingerbread | 400 | 16 | 49 | 3.9 | 16 |
| Honeycomb | 400 | 3.2 | 87 | 6.5 | 45 |
| Lollipop | 400 | 0.2 | 98 | 0 | 2 |
| Jelly bean | 400 | 0 | 94 | 0 | 0 |
| KitKat | 500 | 26 | 65 | 7 | 6 |
| Donut | 500 | 25 | 51 | 4.9 | 22 |
Sort by raw
Using a sortRaw key in your headers object gives you access to all values on the item. This is useful if you want to sort by a value that is not displayed in the table or a combination of multiple values.
Name | Location | Constructed | Description |
|---|---|---|---|
| Great Pyramid of Giza | Egypt | 2584-2561 BC | The oldest and largest of the three pyramids in the Giza pyramid complex. |
| Hanging Gardens of Babylon | Iraq | 600 BC | An ascending series of tiered gardens, said to have been built in ancient Babylon. |
| Statue of Zeus at Olympia | Greece | 435 BC | A giant seated figure of Zeus, made by the sculptor Phidias. |
| Temple of Artemis at Ephesus | Turkey | 550 BC | A large temple dedicated to the goddess Artemis, one of the Seven Wonders of the Ancient World. |
| Mausoleum at Halicarnassus | Turkey | 351 BC | A tomb built for Mausolus, a satrap of the Persian Empire. |
| Colossus of Rhodes | Greece | 292-280 BC | A statue of the Greek sun-god Helios, erected in the city of Rhodes. |
| Lighthouse of Alexandria | Egypt | 280 BC | A lighthouse built by the Ptolemaic Kingdom on the island of Pharos. |
| Great Wall of China | China | 7th century BC - 1644 AD | A series of fortifications made of stone, brick, and other materials. |
| Petra | Jordan | 312 BC | A historical city known for its rock-cut architecture and water conduit system. |
| Taj Mahal | India | 1632-1653 AD | An ivory-white marble mausoleum on the south bank of the Yamuna river. |