BlogPlaygroundOne

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.

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.

  Find a Graphics Card
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-11900K8163.5 GHz5.3 GHz125W
AMD Ryzen 9 5950X16323.4 GHz4.9 GHz105W
Intel Core i7-10700K8163.8 GHz5.1 GHz125W
AMD Ryzen 5 5600X6123.7 GHz4.6 GHz65W
Intel Core i5-10600K6124.1 GHz4.8 GHz125W
AMD Ryzen 7 5800X8163.8 GHz4.7 GHz105W
Intel Core i3-10100483.6 GHz4.3 GHz65W
AMD Ryzen 3 3300X483.8 GHz4.3 GHz65W
Intel Pentium Gold G6400244.0 GHz58W
AMD Athlon 3000G243.5 GHz35W

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 Yogurt15962441
Ice cream sandwich2379374.31
Eclair262162367
Cupcake3053.7674.38
Gingerbread35616493.916

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
Windows3.11
Windows95
Windows98
Windows2000
WindowsXP

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 Yogurt15962441
Ice cream sandwich2379374.31
Eclair262162367
Cupcake3053.7674.38
Gingerbread35616493.916
[]

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 Yogurt15962441
Ice cream sandwich2379374.31
Eclair262162367
Cupcake3053.7674.38
Gingerbread35616493.916

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 Yogurt15962441
Ice cream sandwich2379374.31
Eclair262162367
Cupcake3053.7674.38
Gingerbread35616493.916
Jelly bean37509400
Lollipop3920.29802
Honeycomb4083.2876.545
Donut45225514.922
KitKat518266576

Select strategies

Data-tables support three different select strategies.

StrategyDescription
'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 Yogurt15962441
Ice cream sandwich2379374.31
Eclair262162367
Cupcake3053.7674.38
Gingerbread35616493.916
Jelly bean37509400
Lollipop3920.29802
Honeycomb4083.2876.545
Donut45225514.922
KitKat518266576

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 Yogurt20062441%
Ice cream sandwich2009374.31%
Eclair300162367%
Cupcake3003.7674.38%
Gingerbread40016493.916%
Jelly bean40009400%
Lollipop4000.29802%
Honeycomb4003.2876.545%
Donut50025514.922%
KitKat500266576%
[
  {
    "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.

Dessert (100g serving)
Calories
1
Fat (g)
2
Carbs (g)
Protein (g)
Iron (%)
Ice cream sandwich2009374.31
Frozen Yogurt20062441
Eclair300162367
Cupcake3003.7674.38
Gingerbread40016493.916
Honeycomb4003.2876.545
Lollipop4000.29802
Jelly bean40009400
KitKat500266576
Donut50025514.922

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 GizaEgypt2584-2561 BCThe oldest and largest of the three pyramids in the Giza pyramid complex.
Hanging Gardens of BabylonIraq600 BCAn ascending series of tiered gardens, said to have been built in ancient Babylon.
Statue of Zeus at OlympiaGreece435 BCA giant seated figure of Zeus, made by the sculptor Phidias.
Temple of Artemis at EphesusTurkey550 BCA large temple dedicated to the goddess Artemis, one of the Seven Wonders of the Ancient World.
Mausoleum at HalicarnassusTurkey351 BCA tomb built for Mausolus, a satrap of the Persian Empire.
Colossus of RhodesGreece292-280 BCA statue of the Greek sun-god Helios, erected in the city of Rhodes.
Lighthouse of AlexandriaEgypt280 BCA lighthouse built by the Ptolemaic Kingdom on the island of Pharos.
Great Wall of ChinaChina7th century BC - 1644 ADA series of fortifications made of stone, brick, and other materials.
PetraJordan312 BCA historical city known for its rock-cut architecture and water conduit system.
Taj MahalIndia1632-1653 ADAn ivory-white marble mausoleum on the south bank of the Yamuna river.

Ready for more?

Continue your learning with related content selected by the Team or move between pages by using the navigation links below.