From 5a182c50279341fd1a3366dd5906a0200bc57397 Mon Sep 17 00:00:00 2001 From: "pramod.mahajan" Date: Sun, 28 Dec 2025 12:53:33 +0530 Subject: [PATCH] fixed static data sorting (client side) --- .../collections/PmGridCollection.jsx | 9 +- src/services/pmsGrid/BasicTable.jsx | 22 +- src/services/pmsGrid/PmsGrid.jsx | 6 +- src/services/pmsGrid/PmsHeaderOption.jsx | 2 +- src/services/pmsGrid/useGridCore.js | 211 +++++++++--------- 5 files changed, 128 insertions(+), 122 deletions(-) diff --git a/src/components/collections/PmGridCollection.jsx b/src/components/collections/PmGridCollection.jsx index dcf407f9..f4aefdc0 100644 --- a/src/components/collections/PmGridCollection.jsx +++ b/src/components/collections/PmGridCollection.jsx @@ -12,6 +12,7 @@ const PmGridCollection = ({ selectedProject, fromDate, toDate, isPending }) => { title: "Invoice Number", className: "text-start", groupable: true, + sortable: true, enableAdvancedFilter: false, onCellClick: (row, column) => { console.log("Clicked cell:", row, column); @@ -35,6 +36,7 @@ const PmGridCollection = ({ selectedProject, fromDate, toDate, isPending }) => { key: "exceptedPaymentDate", title: "Expected Payment Date", className: "text-start", + sortable: true, enableAdvancedFilter: { type: "date" }, }, { @@ -148,6 +150,7 @@ const PmGridCollection = ({ selectedProject, fromDate, toDate, isPending }) => { }); }, [grid.sortBy, grid.advanceFilters, grid.groupBy]); + const { data, isLoading, error } = useGridCollectionQuery({ projectId: selectedProject, page: grid.page, @@ -161,9 +164,10 @@ const PmGridCollection = ({ selectedProject, fromDate, toDate, isPending }) => { }); useEffect(() => { + if(!data) return if (data) { - grid.setRows(data.rows); - grid.setTotalRows(data.total); + grid.setServerRows(data.rows); + grid.setServerTotal(data.total); } }, [data]); @@ -174,6 +178,7 @@ const PmGridCollection = ({ selectedProject, fromDate, toDate, isPending }) => { loading={isLoading} features={{ search: true, + selection:true, pagination: true, pinning: true, resizing: true, diff --git a/src/services/pmsGrid/BasicTable.jsx b/src/services/pmsGrid/BasicTable.jsx index 86af3572..09327023 100644 --- a/src/services/pmsGrid/BasicTable.jsx +++ b/src/services/pmsGrid/BasicTable.jsx @@ -621,6 +621,9 @@ const boqColumns = [ sortable: true, pinned: "left", className: "text-start", + onCellClick: (row, column) => { + console.log("Clicked cell:", row, column); + }, }, { key: "description", @@ -714,28 +717,15 @@ export default function DemoBOQGrid() { amount: r.quantity * r.rate, })) }); - - useEffect(() => { - if (!boqData || boqData.length === 0) return; - grid.setRows( - boqData.map((r) => ({ - ...r, - amount: r.quantity * r.rate, - })) - ); - - grid.setTotalRows(boqData.length); - }, [boqData]); - return (
-
- -