diff --git a/src/views/datatable/DataTableDoc.vue b/src/views/datatable/DataTableDoc.vue
index 72e87bfdc..c8a76e29d 100644
--- a/src/views/datatable/DataTableDoc.vue
+++ b/src/views/datatable/DataTableDoc.vue
@@ -570,6 +570,148 @@ export default {
}
}
+
+
Empty Message
+ When there is no data, you may use the empty template to display a message.
+
+
+<DataTable :value="cars">
+ <template #empty>
+ No records found
+ </template>
+ <Column field="vin" header="Vin"></Column>
+ <Column field="year" header="Year"></Column>
+ <Column field="brand" header="Brand"></Column>
+ <Column field="color" header="Color"></Column>
+</DataTable>
+
+
+
+ Loading
+ A loading status indicator can be displayed when the loading property is enabled. The icon is customized through loadingIcon property.
+
+
+<DataTable :value="cars" :loading="loading">
+ <Column field="vin" header="Vin"></Column>
+ <Column field="year" header="Year"></Column>
+ <Column field="brand" header="Brand"></Column>
+ <Column field="color" header="Color"></Column>
+</DataTable>
+
+
+
+
+import CarService from '../../service/CarService';
+
+export default {
+ data() {
+ return {
+ loading: false,
+ cars: null
+ }
+ },
+ datasource: null,
+ carService: null,
+ created() {
+ this.carService = new CarService();
+ },
+ mounted() {
+ this.loading = true;
+
+ this.carService.getCarsLarge().then(data => {
+ this.cars = data
+ this.loading = false;
+ });
+ }
+}
+
+
+ Responsive
+ DataTable display can be optimized according to screen sizes, this example demonstrates a demo where columns are stacked on small screens.
+
+
+<DataTable :value="cars" class="p-datatable-responsive">
+ <template #header>
+ Responsive
+ </template>
+ <Column field="vin" header="Vin">
+ <template #body="slotProps">
+ <span class="p-column-title">Vin</span>
+ {{slotProps.data.vin}}
+ </template>
+ </Column>
+ <Column field="year" header="Year">
+ <template #body="slotProps">
+ <span class="p-column-title">Year</span>
+ {{slotProps.data.year}}
+ </template>
+ </Column>
+ <Column field="brand" header="Brand">
+ <template #body="slotProps">
+ <span class="p-column-title">Brand</span>
+ {{slotProps.data.brand}}
+ </template>
+ </Column>
+ <Column field="color" header="Color">
+ <template #body="slotProps">
+ <span class="p-column-title">Color</span>
+ {{slotProps.data.color}}
+ </template>
+ </Column>
+</DataTable>
+
+
+
+
+import CarService from '../../service/CarService';
+
+export default {
+ data() {
+ return {
+ cars: null
+ }
+ },
+ carService: null,
+ created() {
+ this.carService = new CarService();
+ },
+ mounted() {
+ this.carService.getCarsSmall().then(data => this.cars = data);
+ }
+}
+
+
+
+.p-datatable-responsive .p-datatable-tbody > tr > td .p-column-title {
+ display: none;
+}
+
+@media screen and (max-width: 40em) {
+ .p-datatable-responsive .p-datatable-thead > tr > th,
+ .p-datatable-responsive .p-datatable-tfoot > tr > td {
+ display: none !important;
+ }
+
+ .p-datatable-responsive .p-datatable-tbody > tr > td {
+ text-align: left;
+ display: block;
+ border: 0 none;
+ width: 100% !important;
+ float: left;
+ clear: left;
+ }
+
+ .p-datatable-responsive .p-datatable-tbody > tr > td .p-column-title {
+ padding: .4em;
+ min-width: 30%;
+ display: inline-block;
+ margin: -.4em 1em -.4em -.4em;
+ font-weight: bold;
+ }
+}
+
+
+
Properties