added serverside groupging

This commit is contained in:
pramod.mahajan 2025-11-24 11:22:18 +05:30
parent ee1cf01743
commit e1f72828f9
2 changed files with 100 additions and 39 deletions

View File

@ -39,6 +39,7 @@ export default function PmsGrid({
setPage, setPage,
setPageSize, setPageSize,
setGroupBy, setGroupBy,
groupBy,
search, search,
setSearch, setSearch,
selected, selected,
@ -117,7 +118,7 @@ export default function PmsGrid({
}; };
// group & aggregate (simple client-side grouping by column key) // group & aggregate (simple client-side grouping by column key)
const groupBy = features.groupByKey || null; // const groupBy = features.groupByKey || null;
const groupedRows = React.useMemo(() => { const groupedRows = React.useMemo(() => {
if (!groupBy) return null; if (!groupBy) return null;
const map = {}; const map = {};
@ -187,7 +188,10 @@ export default function PmsGrid({
<li <li
key={c.key} key={c.key}
className="dropdown-item rounded py-1 cursor-pointer" className="dropdown-item rounded py-1 cursor-pointer"
onClick={() => setGroupBy(c.key)} onClick={() => {
setGroupBy(c.key);
groupByKey = c.key;
}}
> >
{c.title} {c.title}
</li> </li>
@ -552,7 +556,7 @@ export default function PmsGrid({
)} )}
</tr> </tr>
{/* 🔹 5. Expanded row content (full width) */} {/* 5. Expanded row content (full width) */}
{isExpanded && renderExpanded && ( {isExpanded && renderExpanded && (
<tr className="table-active"> <tr className="table-active">
<td <td

View File

@ -11,6 +11,8 @@
// <i className="bx bx-dots-vertical-rounded bx-sm text-muted"></i> // <i className="bx bx-dots-vertical-rounded bx-sm text-muted"></i>
// </button> // </button>
import { useEffect } from "react";
// <ul className="dropdown-menu dropdown-menu-end border shadow rounded-3 py-2"> // <ul className="dropdown-menu dropdown-menu-end border shadow rounded-3 py-2">
// <li> // <li>
// <button // <button
@ -53,6 +55,43 @@
// }; // };
// export default PmsHeaderOption; // export default PmsHeaderOption;
const PmsHeaderOption = ({ pinned, onPinLeft, onPinRight, onUnpin }) => { const PmsHeaderOption = ({ pinned, onPinLeft, onPinRight, onUnpin }) => {
const toggleSubmenu = (e) => {
e.stopPropagation();
const currentSubMenu = e.currentTarget.nextElementSibling;
if (!currentSubMenu) return;
const allSubMenus = document.querySelectorAll(
".dropdown-submenu > .dropdown-menu"
);
allSubMenus.forEach((menu) => {
if (menu !== currentSubMenu) {
menu.classList.remove("show");
}
});
currentSubMenu.classList.toggle("show");
};
useEffect(() => {
const handleOutsideClick = () => {
const allSubMenus = document.querySelectorAll(
".dropdown-submenu > .dropdown-menu"
);
allSubMenus.forEach((menu) => {
menu.classList.remove("show");
});
};
document.addEventListener("click", handleOutsideClick);
return () => {
document.removeEventListener("click", handleOutsideClick);
};
}, []);
return ( return (
<div className="dropdown" style={{ zIndex: 9999 }}> <div className="dropdown" style={{ zIndex: 9999 }}>
<button <button
@ -69,18 +108,62 @@ const PmsHeaderOption = ({ pinned, onPinLeft, onPinRight, onUnpin }) => {
<button <button
type="button" type="button"
className="dropdown-item d-flex align-items-center justify-content-between" className="dropdown-item d-flex align-items-center justify-content-between"
onClick={(e) => { onClick={toggleSubmenu}
e.stopPropagation();
e.currentTarget.nextElementSibling.classList.toggle("show");
}}
> >
<span> <span>
<i className="bx bx-pin me-2"></i> Pin <i className="bx bx-left-arrow-alt me-2"></i>
Move Column
</span>
<i className="bx bx-chevron-left"></i>
</button>
<ul className="dropdown-menu border shadow rounded-3 py-2">
<li>
<button
className="dropdown-item d-flex align-items-center"
onClick={() => console.log("Move Left")}
>
<i className="bx bx-arrow-to-left me-2"></i>
Move Left
</button>
</li>
<li>
<button
className="dropdown-item d-flex align-items-center"
onClick={() => console.log("Move Right")}
>
<i className="bx bx-arrow-to-right me-2"></i>
Move Right
</button>
</li>
</ul>
</li>
<li className="dropdown-submenu dropstart">
<button
type="button"
className="dropdown-item d-flex align-items-center justify-content-between"
onClick={toggleSubmenu}
>
<span>
<i className="bx bx-pin me-2"></i> Pin Column
</span> </span>
<i className="bx bx-chevron-right"></i> <i className="bx bx-chevron-right"></i>
</button> </button>
<ul className="dropdown-menu border shadow rounded-3 py-2"> <ul className="dropdown-menu border shadow rounded-3 py-2">
<li>
<button
className="dropdown-item d-flex align-items-center"
onClick={onUnpin}
>
{pinned !== "left" && pinned !== "right" && (
<i className="bx bx-check me-2"></i>
)}
No Pin
</button>
</li>
<li> <li>
<button <button
className={`dropdown-item d-flex align-items-center ${ className={`dropdown-item d-flex align-items-center ${
@ -88,50 +171,24 @@ const PmsHeaderOption = ({ pinned, onPinLeft, onPinRight, onUnpin }) => {
}`} }`}
onClick={onPinLeft} onClick={onPinLeft}
> >
<i className="bx bx-left-arrow-alt me-2"></i> {pinned === "left" && <i className="bx bx-check me-2"></i>}
Left Pin Left
</button> </button>
</li> </li>
<li> <li className="d-flex flex-row gap-2">
<button <button
className={`dropdown-item d-flex align-items-center ${ className={`dropdown-item d-flex align-items-center ${
pinned === "right" ? "active" : "" pinned === "right" ? "active" : ""
}`} }`}
onClick={onPinRight} onClick={onPinRight}
> >
<i className="bx bx-right-arrow-alt me-2"></i> {pinned === "right" && <i className="bx bx-check me-2"></i>}
Right Pin Right
</button> </button>
</li> </li>
</ul> </ul>
</li> </li>
<li>
<button
className={`dropdown-item d-flex align-items-center ${
pinned === "left" ? "active" : ""
}`}
>
<i className="bx bx-left-arrow-alt me-2"></i>
</button>
</li>
{pinned && (
<>
<li>
<hr className="dropdown-divider" />
</li>
<li>
<button
className="dropdown-item text-danger d-flex align-items-center"
onClick={onUnpin}
>
<i className="bx bx-x me-2"></i>
Unpin Column
</button>
</li>
</>
)}
</ul> </ul>
</div> </div>
); );