Skip to main content

Pagination

The footer shows the current range and lets people change page and page size. Pages are zero-based.

Basic usage​

pagination.tsx
import { useState } from 'react';
import { DataGrid, type PaginationModel } from 'expo-flash-datagrid';

import { userColumns, users, type User } from './data';

export function PaginationScreen() {
const [paginationModel, setPaginationModel] = useState<PaginationModel>({
page: 0,
pageSize: 10,
});

return (
<DataGrid<User>
mode="client"
rows={users}
columns={userColumns}
paginationModel={paginationModel}
onPaginationModelChange={setPaginationModel}
pageSizeOptions={[10, 20, 40]}
style={{ flex: 1 }}
/>
);
}

Options​

PropTypeDefaultDescription
paginationModelPaginationModel{ page: 0, pageSize: 25 }Controlled page and size.
onPaginationModelChange(next: PaginationModel) => voidNoneCalled when either changes.
pageSizeOptionsnumber[][10, 25, 50, 100]Sizes offered in the footer.
rowCountnumberrows.lengthTotal rows on the server. Server mode only.

Client vs server​

In client mode the grid slices the processed rows. In server mode, rows must already be the current page, and rowCount tells the footer how many exist.