diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Widgets/TableV2/TableV2_pagination_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Widgets/TableV2/TableV2_pagination_spec.js new file mode 100644 index 0000000000..82a01a6329 --- /dev/null +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Widgets/TableV2/TableV2_pagination_spec.js @@ -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(); + }); +}); diff --git a/app/client/src/widgets/TableWidgetV2/component/Table.tsx b/app/client/src/widgets/TableWidgetV2/component/Table.tsx index 833671e16a..4c88bda8a3 100644 --- a/app/client/src/widgets/TableWidgetV2/component/Table.tsx +++ b/app/client/src/widgets/TableWidgetV2/component/Table.tsx @@ -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 { diff --git a/app/client/src/widgets/TableWidgetV2/component/TableHeader.tsx b/app/client/src/widgets/TableWidgetV2/component/TableHeader.tsx index 75e7a1049f..e1f4a195a4 100644 --- a/app/client/src/widgets/TableWidgetV2/component/TableHeader.tsx +++ b/app/client/src/widgets/TableWidgetV2/component/TableHeader.tsx @@ -290,7 +290,9 @@ function TableHeader(props: TableHeaderProps) { {props.pageNo + 1}   - {`of ${props.pageCount}`} + {`of ${props.pageCount}`} ) : (