Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/seven-tools-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@ensembleui/react-kitchen-sink": patch
"@ensembleui/react-runtime": patch
---

add pageSizeOptions prop to DataGrid for customizable pagination options
1 change: 1 addition & 0 deletions apps/kitchen-sink/src/ensemble/screens/widgets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ View:
selectionType: '${1===10 ? "checkbox" : "radio"}'
allowResizableColumns: true
defaultSelectedRowKeys: ["2"]
pageSizeOptions: [1, 5, 10, 20, 30, 40, 50]
styles:
headerStyle:
backgroundColor: "white"
Expand Down
4 changes: 3 additions & 1 deletion packages/runtime/src/widgets/DataGrid/DataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export type GridProps = {
pageSize?: number;
totalRows?: number;
curPage?: number;
pageSizeOptions?: Expression<number[]>;
virtual?: boolean;
} & EnsembleWidgetProps<DataGridStyles>;

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

// pagination object
const paginationObject = useMemo(() => {
const { hidePagination, totalRows } = values ?? {};
const { hidePagination, totalRows, pageSizeOptions } = values ?? {};

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