Skip to content

Commit c854afe

Browse files
committed
Merge branch 'next' of github.com:devforth/adminforth into next
2 parents d7be863 + 7524b40 commit c854afe

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

adminforth/documentation/docs/tutorial/03-Customization/15-afcl.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -834,8 +834,9 @@ If there is less then `pageSize` rows, pagination will not be shown.
834834
To load pages dynamically, simply pass async callback to data:
835835

836836
```ts
837-
async function loadPageData(offset, limit) {
838-
// in real app do await callAdminForthApi or await fetch to get date, use offset and limit value to slice data
837+
async function loadPageData(data) {
838+
const { offset, limit } = data;
839+
// in real app do await callAdminForthApi or await fetch to get date, use offset and limit value to slice data
839840
return {
840841
data: [
841842
{ name: 'John', age: offset, country: 'US' },
@@ -857,8 +858,9 @@ async function loadPageData(offset, limit) {
857858
//diff-add
858859
:data="loadPageData"
859860

860-
:pageSize="3"
861+
:pageSize="3"> </Table>
861862
```
863+
> 👆 The page size is used as the limit for pagination.
862864
863865
## ProgressBar
864866

adminforth/spa/src/afcl/Table.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
import { IconTableRowOutline } from '@iconify-prerendered/vue-flowbite';
130130
131131
type Row = Record<string, unknown>
132-
type LoadFn = (page: number, pageSize: number) => Promise<{ data: Row[]; total: number }>
132+
type LoadFn = (params: { offset: number, limit: number }) => Promise<{ data: Row[]; total: number }>
133133
134134
const isFunc = (v: unknown): v is LoadFn => typeof v === 'function'
135135
@@ -153,7 +153,7 @@
153153
error.value = null
154154
try {
155155
if (isFunc(props.data)) {
156-
const res = await props.data(page.value, pageSize.value)
156+
const res = await props.data({offset: ((page.value - 1) * pageSize.value), limit: pageSize.value})
157157
if (id !== requestId) return
158158
result.value = res
159159
} else {
@@ -183,7 +183,7 @@
183183
}[],
184184
data: {
185185
[key: string]: any,
186-
}[] | ((offset: number, limit: number) => Promise<{data: {[key: string]: any}[], total: number}>),
186+
}[] | ((params: { offset: number, limit: number }) => Promise<{data: {[key: string]: any}[], total: number}>),
187187
evenHighlights?: boolean,
188188
pageSize?: number,
189189
}>(), {

0 commit comments

Comments
 (0)