Fixed #244 - Loading template for DataTable
parent
2f020a1fcc
commit
c6c419356c
|
@ -30,7 +30,7 @@
|
||||||
<DTTableBody :value="dataToRender" :columns="columns" :empty="empty" :dataKey="dataKey" :selection="selection" :selectionKeys="d_selectionKeys" :selectionMode="selectionMode" :contextMenuSelection="contextMenuSelection"
|
<DTTableBody :value="dataToRender" :columns="columns" :empty="empty" :dataKey="dataKey" :selection="selection" :selectionKeys="d_selectionKeys" :selectionMode="selectionMode" :contextMenuSelection="contextMenuSelection"
|
||||||
:rowGroupMode="rowGroupMode" :groupRowsBy="groupRowsBy" :expandableRowGroups="expandableRowGroups" :rowClass="rowClass" :editMode="editMode" :compareSelectionBy="compareSelectionBy"
|
:rowGroupMode="rowGroupMode" :groupRowsBy="groupRowsBy" :expandableRowGroups="expandableRowGroups" :rowClass="rowClass" :editMode="editMode" :compareSelectionBy="compareSelectionBy"
|
||||||
:expandedRowIcon="expandedRowIcon" :collapsedRowIcon="collapsedRowIcon" :expandedRows="expandedRows" :expandedRowKeys="d_expandedRowKeys" :expandedRowGroups="expandedRowGroups"
|
:expandedRowIcon="expandedRowIcon" :collapsedRowIcon="collapsedRowIcon" :expandedRows="expandedRows" :expandedRowKeys="d_expandedRowKeys" :expandedRowGroups="expandedRowGroups"
|
||||||
:editingRows="editingRows" :editingRowKeys="d_editingRowKeys" :templates="$scopedSlots"
|
:editingRows="editingRows" :editingRowKeys="d_editingRowKeys" :templates="$scopedSlots" :loading="loading"
|
||||||
@rowgroup-toggle="toggleRowGroup" @row-click="onRowClick($event)" @row-rightclick="onRowRightClick($event)" @row-touchend="onRowTouchEnd" @row-keydown="onRowKeyDown"
|
@rowgroup-toggle="toggleRowGroup" @row-click="onRowClick($event)" @row-rightclick="onRowRightClick($event)" @row-touchend="onRowTouchEnd" @row-keydown="onRowKeyDown"
|
||||||
@row-mousedown="onRowMouseDown" @row-dragstart="onRowDragStart($event)" @row-dragover="onRowDragOver($event)" @row-dragleave="onRowDragLeave($event)" @row-dragend="onRowDragEnd($event)" @row-drop="onRowDrop($event)"
|
@row-mousedown="onRowMouseDown" @row-dragstart="onRowDragStart($event)" @row-dragover="onRowDragOver($event)" @row-dragleave="onRowDragLeave($event)" @row-dragend="onRowDragEnd($event)" @row-drop="onRowDrop($event)"
|
||||||
@row-toggle="toggleRow($event)" @radio-change="toggleRowWithRadio($event)" @checkbox-change="toggleRowWithCheckbox($event)"
|
@row-toggle="toggleRow($event)" @radio-change="toggleRowWithRadio($event)" @checkbox-change="toggleRowWithCheckbox($event)"
|
||||||
|
|
|
@ -36,7 +36,8 @@
|
||||||
</template>
|
</template>
|
||||||
<tr v-else class="p-datatable-emptymessage">
|
<tr v-else class="p-datatable-emptymessage">
|
||||||
<td :colspan="columns.length">
|
<td :colspan="columns.length">
|
||||||
<DTEmptySlotTemplate :template="templates.empty" v-if="templates.empty"/>
|
<DTSlotTemplate :template="templates.empty" v-if="templates.empty && !loading"/>
|
||||||
|
<DTSlotTemplate :template="templates.loading" v-if="templates.loading && loading"/>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -75,7 +76,7 @@ const RowExpansionTemplate = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const EmptySlotTemplate = {
|
const SlotTemplate = {
|
||||||
functional: true,
|
functional: true,
|
||||||
props: {
|
props: {
|
||||||
template: {
|
template: {
|
||||||
|
@ -175,6 +176,10 @@ export default {
|
||||||
type: null,
|
type: null,
|
||||||
default: null
|
default: null
|
||||||
},
|
},
|
||||||
|
loading: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
templates: {
|
templates: {
|
||||||
type: null,
|
type: null,
|
||||||
default: null
|
default: null
|
||||||
|
@ -435,7 +440,7 @@ export default {
|
||||||
components: {
|
components: {
|
||||||
'DTBodyCell': BodyCell,
|
'DTBodyCell': BodyCell,
|
||||||
'DTRowExpansionTemplate': RowExpansionTemplate,
|
'DTRowExpansionTemplate': RowExpansionTemplate,
|
||||||
'DTEmptySlotTemplate': EmptySlotTemplate
|
'DTSlotTemplate': SlotTemplate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
|
@ -13,7 +13,7 @@
|
||||||
<div class="p-card">
|
<div class="p-card">
|
||||||
<div class="p-card-body" style="padding:0">
|
<div class="p-card-body" style="padding:0">
|
||||||
<DataTable :value="customers" :paginator="true" class="p-datatable-customers" :rows="10"
|
<DataTable :value="customers" :paginator="true" class="p-datatable-customers" :rows="10"
|
||||||
dataKey="id" :rowHover="true" :selection.sync="selectedCustomers" :filters="filters"
|
dataKey="id" :rowHover="true" :selection.sync="selectedCustomers" :filters="filters" :loading="loading"
|
||||||
paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown" :rowsPerPageOptions="[10,25,50]"
|
paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown" :rowsPerPageOptions="[10,25,50]"
|
||||||
currentPageReportTemplate="Showing {first} to {last} of {totalRecords} entries">
|
currentPageReportTemplate="Showing {first} to {last} of {totalRecords} entries">
|
||||||
<template #header>
|
<template #header>
|
||||||
|
@ -25,6 +25,9 @@
|
||||||
<template #empty>
|
<template #empty>
|
||||||
No customers found.
|
No customers found.
|
||||||
</template>
|
</template>
|
||||||
|
<template #loading>
|
||||||
|
Loading customers data. Please wait.
|
||||||
|
</template>
|
||||||
<Column selectionMode="multiple" headerStyle="width: 3em"></Column>
|
<Column selectionMode="multiple" headerStyle="width: 3em"></Column>
|
||||||
<Column field="name" header="Name" :sortable="true">
|
<Column field="name" header="Name" :sortable="true">
|
||||||
<template #body="slotProps">
|
<template #body="slotProps">
|
||||||
|
@ -115,6 +118,7 @@ export default {
|
||||||
customers: null,
|
customers: null,
|
||||||
selectedCustomers: null,
|
selectedCustomers: null,
|
||||||
filters: {},
|
filters: {},
|
||||||
|
loading: true,
|
||||||
representatives: [
|
representatives: [
|
||||||
{name: "Amy Elsner", image: 'amyelsner.png'},
|
{name: "Amy Elsner", image: 'amyelsner.png'},
|
||||||
{name: "Anna Fali", image: 'annafali.png'},
|
{name: "Anna Fali", image: 'annafali.png'},
|
||||||
|
@ -137,6 +141,7 @@ export default {
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.customerService.getCustomersLarge().then(data => this.customers = data);
|
this.customerService.getCustomersLarge().then(data => this.customers = data);
|
||||||
|
this.loading = false;
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
filterDate(value, filter) {
|
filterDate(value, filter) {
|
||||||
|
|
|
@ -1476,10 +1476,14 @@ export default {
|
||||||
</CodeHighlight>
|
</CodeHighlight>
|
||||||
|
|
||||||
<h3>Loading</h3>
|
<h3>Loading</h3>
|
||||||
<p>A loading status indicator can be displayed when the <i>loading</i> property is enabled. The icon is customized through <i>loadingIcon</i> property.</p>
|
<p>A loading status indicator can be displayed when the <i>loading</i> property is enabled. The icon is customized through <i>loadingIcon</i> property. Additionally
|
||||||
|
an option loading template is available to render as the body until the data is loaded.</p>
|
||||||
<CodeHighlight>
|
<CodeHighlight>
|
||||||
<template v-pre>
|
<template v-pre>
|
||||||
<DataTable :value="cars" :loading="loading">
|
<DataTable :value="cars" :loading="loading">
|
||||||
|
<template #loading>
|
||||||
|
Loading records, please wait...
|
||||||
|
</template>
|
||||||
<Column field="vin" header="Vin"></Column>
|
<Column field="vin" header="Vin"></Column>
|
||||||
<Column field="year" header="Year"></Column>
|
<Column field="year" header="Year"></Column>
|
||||||
<Column field="brand" header="Brand"></Column>
|
<Column field="brand" header="Brand"></Column>
|
||||||
|
@ -2331,7 +2335,7 @@ export default {
|
||||||
<div class="p-card">
|
<div class="p-card">
|
||||||
<div class="p-card-body" style="padding:0">
|
<div class="p-card-body" style="padding:0">
|
||||||
<DataTable :value="customers" :paginator="true" class="p-datatable-responsive p-datatable-customers" :rows="10"
|
<DataTable :value="customers" :paginator="true" class="p-datatable-responsive p-datatable-customers" :rows="10"
|
||||||
dataKey="id" :rowHover="true" :selection.sync="selectedCustomers" :filters="filters"
|
dataKey="id" :rowHover="true" :selection.sync="selectedCustomers" :filters="filters" :loading="loading"
|
||||||
paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown" :rowsPerPageOptions="[10,25,50]"
|
paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown" :rowsPerPageOptions="[10,25,50]"
|
||||||
currentPageReportTemplate="Showing {first} to {last} of {totalRecords} entries">
|
currentPageReportTemplate="Showing {first} to {last} of {totalRecords} entries">
|
||||||
<template #header>
|
<template #header>
|
||||||
|
@ -2343,6 +2347,9 @@ export default {
|
||||||
<template #empty>
|
<template #empty>
|
||||||
No customers found.
|
No customers found.
|
||||||
</template>
|
</template>
|
||||||
|
<template #loading>
|
||||||
|
Loading customers data. Please wait.
|
||||||
|
</template>
|
||||||
<Column selectionMode="multiple" headerStyle="width: 3em"></Column>
|
<Column selectionMode="multiple" headerStyle="width: 3em"></Column>
|
||||||
<Column field="name" header="Name" :sortable="true">
|
<Column field="name" header="Name" :sortable="true">
|
||||||
<template #body="slotProps">
|
<template #body="slotProps">
|
||||||
|
@ -2427,6 +2434,7 @@ export default {
|
||||||
customers: null,
|
customers: null,
|
||||||
selectedCustomers: null,
|
selectedCustomers: null,
|
||||||
filters: {},
|
filters: {},
|
||||||
|
loading: true,
|
||||||
representatives: [
|
representatives: [
|
||||||
{name: "Amy Elsner", image: 'amyelsner.png'},
|
{name: "Amy Elsner", image: 'amyelsner.png'},
|
||||||
{name: "Anna Fali", image: 'annafali.png'},
|
{name: "Anna Fali", image: 'annafali.png'},
|
||||||
|
@ -2448,7 +2456,10 @@ export default {
|
||||||
this.customerService = new CustomerService();
|
this.customerService = new CustomerService();
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.customerService.getCustomersLarge().then(data => this.customers = data);
|
this.customerService.getCustomersLarge().then(data => {
|
||||||
|
this.customers = data;
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
filterDate(value, filter) {
|
filterDate(value, filter) {
|
||||||
|
|
Loading…
Reference in New Issue