# Table
Displays a data table. Note: This component is a wrapper of the Bootstrap-Vue Table component (opens new window).
# Example
Code:
<template>
<div class="margin-top-2">
<Table :columns="columns" :rows="rows" :shouldDisplayFilter="true" breakpoint="680px" >
<!-- Custom cell render slot -->
<template v-slot:cell(Column5)="data">
<a href="#">{{ data.value }}</a>
</template>
<!-- Row drilldown/details functionality -->
<template v-slot:cell(Column6)="row">
<Button label="Drilldown" @click="row.toggleDetails" />
</template>
<template v-slot:row-details="row">
<Alert type="warning" :text="row.item.Column2" />
</template>
</Table>
</div>
</template>
<script>
export default {
data() {
return {
columns: [
{ key: 'Column1', label: 'Left Column', tdClass: 'text-left' },
{ key: 'Column2', label: 'Center Column', hideOnBreakpoint: 'tablet-lg' },
{ key: 'Column3', label: 'Right Column', tdClass: 'text-right', hideOnBreakpoint: 'desktop' },
{ key: 'Column4', label: 'Sort-Disabled Column', sortable: false },
{ key: 'Column5', label: 'Custom Cell Render' },
{ key: 'Column6', label: 'Drilldown', sortable: false },
],
rows: [
{ Column1: '1 test', Column2: 'a test', Column3: 'test', Column4: 'test', Column5: 'link1', Column6: 'test' },
{ Column1: '2 test', Column2: 'b test', Column3: 'test', Column4: 'test', Column5: 'link2', Column6: 'test' },
{ Column1: '3 test', Column2: 'c test', Column3: 'test', Column4: 'test', Column5: 'link3', Column6: 'test' },
{ Column1: '4 test', Column2: 'd test', Column3: 'test', Column4: 'test', Column5: 'link4', Column6: 'test' },
{ Column1: '5 test', Column2: 'e test', Column3: 'test', Column4: 'test', Column5: 'link5', Column6: 'test' },
],
};
},
};
</script>
# Props
*Required
Name | Type | Description | Default |
---|---|---|---|
columns* | Array | For a simple table, this can be an array of strings for column headers. Otherwise, use an array of objects (see below) | |
rows* | Array | Array of objects with the object keys matching column keys. | |
defaultSort | String | Set the column key that should be sorted on by default. | |
busy | Boolean | If true, table will display a loading indicator. Used when fetching data. | false |
shouldDisplayFilter | Boolean | Displays a text filter to search table's content. | false |
# Columns Array
hideOnBreakpoint
Add hideOnBreakpoint prop to field object to hide specific columns depending on screen size. Currently available breakpoints (following USWDS) are below. Use the screen type as the value of hideOnBreakpoint, e.g. hideOnBreakpoint: 'tablet'
desktop-lg
- 1200pxdesktop
- 1040pxtablet-lg
- 800pxtablet
- 640px
See the Bootstrap-Vue Table fields documentation (opens new window) for how to build the field objects.