Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OBSDEF-44980] Show pagination footer with page sizes dropdown only if number of records are greater than 10 #283

Merged
merged 2 commits into from
May 15, 2024
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dellstorage/clarity-react",
"version": "1.2.12",
"version": "1.2.13",
"description": "React components for Clarity UI",
"license": "Apache-2.0",
"private": false,
Expand Down
15 changes: 14 additions & 1 deletion src/datagrid/DataGrid.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import {
paginationRowsWithLinks,
storeForDetailPane,
paginationDetailswithPageSizes,
paginationDetailsForLessThan10Records,
} from "./DataGridStoriesData";
import {CustomFilter} from "./CustomFilter";
import {CustomFilterMulti} from "./CustomFilterMulti";
Expand Down Expand Up @@ -421,14 +422,26 @@ storiesOf("DataGrid", module)
</div>
))
.add("Grid with pagination and custom page size", () => (
<div style={{width: "80%"}}>
<div style={{width: "80%", paddingLeft: "1rem"}}>
<br />
<span> {"Datagrid with custom page sizes and more than or equal to 10 records."} </span>
<DataGrid
columns={normalColumns}
rows={paginationRows.slice(0, 10)}
pagination={paginationDetailswithPageSizes}
itemText={"Users"}
footer={{showFooter: true}}
/>
<br /> <br />
<span> {"Datagrid with custom page sizes and less than 10 records."} </span>
<DataGrid
columns={normalColumns}
rows={paginationRows.slice(0, 6)}
pagination={paginationDetailsForLessThan10Records}
itemText={"Users"}
footer={{showFooter: true}}
/>
<br /> <br />
</div>
))
.add("Grid with pagination and compact footer", () => (
Expand Down
2 changes: 1 addition & 1 deletion src/datagrid/DataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1721,7 +1721,7 @@ export class DataGrid extends React.PureComponent<DataGridProps, DataGridState>
const {totalItems, pageSize, pageSizes} = pagination;
if (totalItems && pageSize) {
// Render pagination footer if pageSizes are given or if totalItems are greater than pageSize
renderPaginationFooter = pageSizes ? totalItems > 0 : totalItems >= pageSize;
renderPaginationFooter = pageSizes ? totalItems >= DEFAULT_PAGE_SIZE : totalItems >= pageSize;
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/datagrid/DataGridStoriesData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,14 @@ export const paginationDetailswithPageSizes: DataGridPaginationProps = {
pageSizes: ["10", "20", "50", "100", CUSTOM_PAGE_SIZE_OPTION],
};

export const paginationDetailsForLessThan10Records: DataGridPaginationProps = {
totalItems: 6,
getPageData: getPageDataForCustomPageSize,
pageSize: 10,
currentPage: 1,
pageSizes: ["10", "20", "50", "100", CUSTOM_PAGE_SIZE_OPTION],
};

export const paginationDetailsWithCompactFooter: DataGridPaginationProps = {
totalItems: paginationRows.length,
getPageData: getPageData,
Expand Down
Loading