Skip to content

Commit 7ac0f81

Browse files
authored
add pageSizeOptions prop to DataGrid for customizable pagination options (#1127)
1 parent 66ddbe3 commit 7ac0f81

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

.changeset/seven-tools-explain.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@ensembleui/react-kitchen-sink": patch
3+
"@ensembleui/react-runtime": patch
4+
---
5+
6+
add pageSizeOptions prop to DataGrid for customizable pagination options

apps/kitchen-sink/src/ensemble/screens/widgets.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ View:
298298
selectionType: '${1===10 ? "checkbox" : "radio"}'
299299
allowResizableColumns: true
300300
defaultSelectedRowKeys: ["2"]
301+
pageSizeOptions: [1, 5, 10, 20, 30, 40, 50]
301302
styles:
302303
headerStyle:
303304
backgroundColor: "white"

packages/runtime/src/widgets/DataGrid/DataGrid.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ export type GridProps = {
114114
pageSize?: number;
115115
totalRows?: number;
116116
curPage?: number;
117+
pageSizeOptions?: Expression<number[]>;
117118
virtual?: boolean;
118119
} & EnsembleWidgetProps<DataGridStyles>;
119120

@@ -427,7 +428,7 @@ export const DataGrid: React.FC<GridProps> = (props) => {
427428

428429
// pagination object
429430
const paginationObject = useMemo(() => {
430-
const { hidePagination, totalRows } = values ?? {};
431+
const { hidePagination, totalRows, pageSizeOptions } = values ?? {};
431432

432433
if (hidePagination || !pageSize) {
433434
return false;
@@ -438,6 +439,7 @@ export const DataGrid: React.FC<GridProps> = (props) => {
438439
pageSize,
439440
total: totalRows,
440441
current: curPage,
442+
pageSizeOptions: pageSizeOptions as number[] | undefined,
441443
showSizeChanger: true, // always show pagination options (otherwise it defaults to total > 50)
442444
};
443445
}, [values, pageSize, curPage, resolvedWidgetId]);

0 commit comments

Comments
 (0)