Skip to content

Commit b3be8d2

Browse files
Updated playground template
1 parent d5f8e5a commit b3be8d2

File tree

1 file changed

+95
-11
lines changed

1 file changed

+95
-11
lines changed

src/playground/configs/PlaygroundPage.template.vue

Lines changed: 95 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@
1010
:density="tableSettings.density"
1111
:drilldown-key="tableSettings.drilldownKey"
1212
:elevation="tableSettings.elevation"
13+
:footers="tableSettings.footers.users"
1314
:headers="tableSettings.headers.users"
1415
:hover="tableSettings.hover"
1516
:items="tableSettings.items"
17+
:items-length="tableSettings.itemsLength"
1618
:items-per-page="tableSettings.itemsPerPage"
1719
:levels="tableSettings.levels"
20+
:show-footer-row="tableSettings.showFooterRow"
1821
:show-search="tableSettings.showSearch"
1922
@drilldown="fetchData($event)"
2023
>
@@ -47,8 +50,6 @@
4750
:item-value="tableSettings.itemValue"
4851
:items="defaultTableItems"
4952
:items-per-page="tableSettings.itemsPerPage"
50-
:loading="tableSettings.loading"
51-
:loading-text="tableSettings.loadingText"
5253
:multi-sort="tableSettings.multiSort"
5354
:no-data-text="tableSettings.noDataText"
5455
:page="tableSettings.page"
@@ -66,12 +67,6 @@
6667
</td>
6768
</tr>
6869
</template>
69-
70-
<template #[`footer.prepend`]>
71-
<div class="me-2">
72-
[footer.prepend Slot]
73-
</div>
74-
</template>
7570
</v-data-table>
7671
</v-col>
7772
</v-row>
@@ -85,7 +80,6 @@ onMounted(() => {
8580
fetchComments();
8681
});
8782
88-
8983
const tableSettings = ref({
9084
colors: {
9185
body: {
@@ -125,6 +119,85 @@ const tableSettings = ref({
125119
fixedHeader: true, // ! Failed
126120
// footerProps: {}, // ? In v2 Missing in v3
127121
// groupBy: [], // * Works, but this does not look very good by default
122+
footers: {
123+
comments: [
124+
{
125+
title: '',
126+
align: 'start',
127+
key: null,
128+
width: 100,
129+
},
130+
{
131+
title: 'Post ID',
132+
align: 'start',
133+
key: 'postId',
134+
width: 100,
135+
},
136+
{
137+
title: 'Comment ID',
138+
align: 'start',
139+
key: 'id',
140+
width: 150,
141+
},
142+
{
143+
title: 'Comment',
144+
align: 'start',
145+
key: 'name',
146+
},
147+
{
148+
key: 'data-table-expand',
149+
title: '',
150+
},
151+
],
152+
posts: [
153+
{
154+
title: 'User ID',
155+
align: 'start',
156+
key: 'userId',
157+
width: 100,
158+
},
159+
{
160+
title: 'Post ID',
161+
align: 'start',
162+
key: 'id',
163+
width: 250,
164+
},
165+
{
166+
title: 'Post',
167+
align: 'start',
168+
key: 'title',
169+
},
170+
{
171+
key: 'data-table-expand',
172+
title: '',
173+
},
174+
],
175+
users: [
176+
{
177+
title: 'User ID',
178+
align: 'start',
179+
key: 'id',
180+
width: 350,
181+
},
182+
{
183+
title: 'Name',
184+
align: 'start',
185+
key: 'name',
186+
},
187+
{
188+
title: 'Email',
189+
align: 'start',
190+
key: 'email',
191+
renderCell() {
192+
return 'Total';
193+
},
194+
},
195+
{
196+
key: 'data-table-expand',
197+
title: '',
198+
},
199+
],
200+
},
128201
headers: {
129202
comments: [
130203
{
@@ -194,6 +267,9 @@ const tableSettings = ref({
194267
title: 'Email',
195268
align: 'start',
196269
key: 'email',
270+
// renderFooter() {
271+
// return 'Total';
272+
// },
197273
},
198274
{
199275
key: 'data-table-expand',
@@ -211,10 +287,11 @@ const tableSettings = ref({
211287
itemTitle: 'title', // * Works, but is weird
212288
itemValue: 'id', // * Works, but is weird
213289
items: [],
290+
itemsLength: 0,
214291
itemsPerPage: 10, // * Works
215292
levels: 2, // * Works - Custom Prop
216-
loading: false, // ! Failed - https://github.com/vuetifyjs/vuetify/issues/16811
217-
loadingText: 'Loading...', // ! Failed - https://github.com/vuetifyjs/vuetify/issues/16811
293+
// loading: false, // ! Failed - https://github.com/vuetifyjs/vuetify/issues/16811
294+
// loadingText: 'Loading...', // ! Failed - https://github.com/vuetifyjs/vuetify/issues/16811
218295
// modelValue: [], // ? Needs Testing
219296
multiSort: false, // * Works
220297
mustSort: false, // * Works
@@ -237,6 +314,7 @@ const tableSettings = ref({
237314
variant: 'underlined',
238315
},
239316
// server: false, // ? Needs Testing. This requires v-data-table-server
317+
showFooterRow: true,
240318
showSearch: false,
241319
showExpand: false, // * Works
242320
showSelect: false, // * Works
@@ -248,6 +326,7 @@ const tableSettings = ref({
248326
249327
function fetchData(drilldown = null) {
250328
const item = drilldown?.item?.raw ?? null;
329+
// tableSettings.value.loading = true;
251330
252331
let url = 'https://jsonplaceholder.typicode.com/users';
253332
let user = null;
@@ -269,9 +348,12 @@ function fetchData(drilldown = null) {
269348
.then(response => response.json())
270349
.then(json => {
271350
// console.log('fetch response', json);
351+
tableSettings.value.itemsLength = json.length;
352+
272353
273354
if (!drilldown) {
274355
tableSettings.value.items = json;
356+
// tableSettings.value.loading = false;
275357
return;
276358
}
277359
@@ -284,6 +366,7 @@ function fetchData(drilldown = null) {
284366
285367
drilldownKey: 'id',
286368
headers: [...tableSettings.value.headers.posts],
369+
footers: [...tableSettings.value.footers.posts],
287370
items: [...json],
288371
level: 1,
289372
};
@@ -296,6 +379,7 @@ function fetchData(drilldown = null) {
296379
post.children = {
297380
drilldownKey: 'id',
298381
headers: [...tableSettings.value.headers.comments],
382+
footers: [...tableSettings.value.footers.comments],
299383
items: [...json],
300384
level: 2,
301385
};

0 commit comments

Comments
 (0)