From 17b5b9d535e2117d77f7bb3eecbfb02ae174f1b1 Mon Sep 17 00:00:00 2001 From: Satbir Singh Date: Thu, 23 Jan 2020 12:15:11 +0000 Subject: [PATCH] Fixing the selected row issue due to pagination --- .../designSystems/syncfusion/TableComponent.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/client/src/components/designSystems/syncfusion/TableComponent.tsx b/app/client/src/components/designSystems/syncfusion/TableComponent.tsx index d922716755..3b40912a1c 100644 --- a/app/client/src/components/designSystems/syncfusion/TableComponent.tsx +++ b/app/client/src/components/designSystems/syncfusion/TableComponent.tsx @@ -12,6 +12,7 @@ import { CommandColumn, CommandModel, CommandClickEventArgs, + PageSettingsModel, } from "@syncfusion/ej2-react-grids"; import React, { useRef, MutableRefObject, useEffect, memo } from "react"; import styled from "constants/DefaultTheme"; @@ -42,6 +43,7 @@ const settings: SelectionSettingsModel = { type GridRef = MutableRefObject; function reCalculatePageSize(grid: GridRef, height: number) { + console.log(""); if (grid.current) { const rowHeight: number = grid.current.getRowHeight(); /** Grid height */ @@ -101,7 +103,18 @@ const TableComponent = memo( /** Get the selected records. */ const selectedrecords: object[] = grid.current.getSelectedRecords(); if (selectedrecords.length !== 0) { - props.onRowClick(selectedrecords[0], selectedrowindex[0]); + let index = selectedrowindex[0]; + const pageSettings: PageSettingsModel = grid.current.pageSettings; + if ( + pageSettings && + pageSettings.currentPage !== undefined && + pageSettings.pageSize !== undefined + ) { + index = + index + (pageSettings.currentPage - 1) * pageSettings.pageSize; + } + + props.onRowClick(selectedrecords[0], index); } } }