fix: Incorrect page count when number of records in page is different from page size (#17535)
This commit is contained in:
parent
ea070517d3
commit
408d116c44
|
|
@ -0,0 +1,22 @@
|
|||
const commonlocators = require("../../../../../locators/commonlocators.json");
|
||||
const dsl = require("../../../../../fixtures/tableV2NewDslWithPagination.json");
|
||||
|
||||
describe("Table Widget property pane feature validation", function() {
|
||||
before(() => {
|
||||
cy.addDsl(dsl);
|
||||
});
|
||||
|
||||
it("1. Verify table column type changes effect on menuButton and iconButton", function() {
|
||||
cy.openPropertyPane("tablewidgetv2");
|
||||
cy.CheckWidgetProperties(commonlocators.serverSidePaginationCheckbox);
|
||||
cy.get(".t--property-control-totalrecords pre.CodeMirror-line span span")
|
||||
.click()
|
||||
.type("26");
|
||||
cy.wait(1000);
|
||||
cy.get(`.t--draggable-tablewidgetv2 span[data-pagecount="20"]`).should(
|
||||
"exist",
|
||||
);
|
||||
|
||||
cy.closePropertyPane();
|
||||
});
|
||||
});
|
||||
|
|
@ -137,9 +137,17 @@ export function Table(props: TableProps) {
|
|||
}),
|
||||
[columnString],
|
||||
);
|
||||
/*
|
||||
For serverSidePaginationEnabled we are taking props.data.length as the page size.
|
||||
As props.pageSize is being set by the visible number of rows in the table (without scrolling),
|
||||
it will not give the correct count of records in the current page when query limit
|
||||
is set higher/lower than the visible number of rows in the table
|
||||
*/
|
||||
const pageCount =
|
||||
props.serverSidePaginationEnabled && props.totalRecordsCount
|
||||
? Math.ceil(props.totalRecordsCount / props.pageSize)
|
||||
props.serverSidePaginationEnabled &&
|
||||
props.totalRecordsCount &&
|
||||
props.data.length
|
||||
? Math.ceil(props.totalRecordsCount / props.data.length)
|
||||
: Math.ceil(props.data.length / props.pageSize);
|
||||
const currentPageIndex = props.pageNo < pageCount ? props.pageNo : 0;
|
||||
const {
|
||||
|
|
|
|||
|
|
@ -290,7 +290,9 @@ function TableHeader(props: TableHeaderProps) {
|
|||
{props.pageNo + 1}
|
||||
</PaginationItemWrapper>
|
||||
|
||||
<span>{`of ${props.pageCount}`}</span>
|
||||
<span
|
||||
data-pagecount={props.pageCount}
|
||||
>{`of ${props.pageCount}`}</span>
|
||||
</TableHeaderContentWrapper>
|
||||
) : (
|
||||
<PaginationItemWrapper
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user