Skip to content

Commit cb62f04

Browse files
committed
dev-demo: add example of table with backend pagination
1 parent d4a16f9 commit cb62f04

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

dev-demo/custom/AfComponents.vue

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,19 @@
242242
:pageSize="3"
243243
>
244244
</Table>
245+
<div>
246+
Backend pagination ⬇️
247+
<Table
248+
:columns="[
249+
{ label: 'Name', fieldName: 'name' },
250+
{ label: 'Age', fieldName: 'age' },
251+
{ label: 'Country', fieldName: 'country' },
252+
]"
253+
:data="loadPageData"
254+
255+
:pageSize="3">
256+
</Table>
257+
</div>
245258

246259
<div class="w-full">
247260
<p class="text-sm font-semibold text-lightPrimary dark:text-darkPrimary mb-2">TreeMapChart (value + delta)</p>
@@ -487,4 +500,18 @@ async function createJob() {
487500
}
488501
}
489502
503+
async function loadPageData(data) {
504+
const { offset, limit } = data;
505+
// in real app do await callAdminForthApi or await fetch to get date, use offset and limit value to slice data
506+
await new Promise(resolve => setTimeout(resolve, 1000)) // simulate network delay
507+
return {
508+
data: [
509+
{ name: 'John', age: offset, country: 'US' },
510+
{ name: 'Rick', age: offset+1, country: 'CA' },
511+
{ name: 'Alice', age: offset+2, country: 'BR' },
512+
],
513+
total: 30 // should return total amount of records in database
514+
}
515+
}
516+
490517
</script>

0 commit comments

Comments
 (0)