added onCell click event
This commit is contained in:
parent
fd89bfead8
commit
468797f823
@ -12,6 +12,9 @@ const PmGridCollection = ({ selectedProject, fromDate, toDate, isPending }) => {
|
|||||||
className: "text-start",
|
className: "text-start",
|
||||||
groupable: true,
|
groupable: true,
|
||||||
enableAdvancedFilter: false,
|
enableAdvancedFilter: false,
|
||||||
|
onCellClick: (row, column) => {
|
||||||
|
console.log("Clicked cell:", row, column);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "title",
|
key: "title",
|
||||||
@ -123,7 +126,7 @@ const PmGridCollection = ({ selectedProject, fromDate, toDate, isPending }) => {
|
|||||||
{
|
{
|
||||||
label: "Edit",
|
label: "Edit",
|
||||||
icon: "bx-edit ",
|
icon: "bx-edit ",
|
||||||
onClick: (row) => console.log("Edit", row),
|
onClick: (row) => console.log("Edit", row, col),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Delete",
|
label: "Delete",
|
||||||
|
|||||||
@ -216,7 +216,8 @@ const boqData = [
|
|||||||
id: 18,
|
id: 18,
|
||||||
category: "Waterproofing Works",
|
category: "Waterproofing Works",
|
||||||
itemCode: "W-002",
|
itemCode: "W-002",
|
||||||
description: "Polyurethane Waterproofing Membrane Polyurethane Waterproofing Membrane",
|
description:
|
||||||
|
"Polyurethane Waterproofing Membrane Polyurethane Waterproofing Membrane",
|
||||||
unit: "Sqm",
|
unit: "Sqm",
|
||||||
quantity: 200,
|
quantity: 200,
|
||||||
rate: 850,
|
rate: 850,
|
||||||
@ -610,7 +611,6 @@ const boqData = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* COLUMN DEFINITIONS
|
* COLUMN DEFINITIONS
|
||||||
*/
|
*/
|
||||||
@ -718,31 +718,25 @@ export default function DemoBOQGrid() {
|
|||||||
return () => ps.destroy();
|
return () => ps.destroy();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const container = document.getElementById("mainContainer");
|
const container = document.getElementById("mainContainer");
|
||||||
const trigger = document.getElementById("dropdownBtn");
|
const trigger = document.getElementById("dropdownBtn");
|
||||||
const dropdown = document.getElementById("dropdownMenu");
|
const dropdown = document.getElementById("dropdownMenu");
|
||||||
|
|
||||||
trigger.addEventListener("click", () => {
|
|
||||||
dropdown.classList.toggle("show");
|
|
||||||
autoPositionInsideContainer(trigger, dropdown, container);
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container-fluid py-3">
|
<div className="container-fluid py-3">
|
||||||
<div className="card p-3">
|
<div className="card p-3">
|
||||||
<div id="mainContainer" class="container-box">
|
<div id="mainContainer" class="container-box">
|
||||||
<button id="dropdownBtn" class="btn">Open Dropdown</button>
|
<button id="dropdownBtn" class="btn">
|
||||||
|
Open Dropdown
|
||||||
|
</button>
|
||||||
|
|
||||||
<div id="dropdownMenu" class="dropdown-menu">
|
<div id="dropdownMenu" class="dropdown-menu">
|
||||||
<div>Option 1</div>
|
<div>Option 1</div>
|
||||||
<div>Option 2</div>
|
<div>Option 2</div>
|
||||||
<div>Option 3</div>
|
<div>Option 3</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<PmsGrid
|
<PmsGrid
|
||||||
data={boqData.map((r) => ({
|
data={boqData.map((r) => ({
|
||||||
...r,
|
...r,
|
||||||
@ -767,14 +761,13 @@ trigger.addEventListener("click", () => {
|
|||||||
{
|
{
|
||||||
label: "Edit",
|
label: "Edit",
|
||||||
icon: "bx-edit ",
|
icon: "bx-edit ",
|
||||||
onClick: (row) => console.log("Edit", row),
|
onClick: (row,ind,column) => console.log("Edit", row,ind,column),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Delete",
|
label: "Delete",
|
||||||
icon: "bx-trash text-danger",
|
icon: "bx-trash text-danger",
|
||||||
onClick: (row) => console.log("Delete", row),
|
onClick: (row) => console.log("Delete", row),
|
||||||
},
|
},
|
||||||
|
|
||||||
],
|
],
|
||||||
}}
|
}}
|
||||||
renderExpanded={(row) => (
|
renderExpanded={(row) => (
|
||||||
|
|||||||
@ -24,6 +24,7 @@ export default function PmsGrid({
|
|||||||
renderExpanded,
|
renderExpanded,
|
||||||
}) {
|
}) {
|
||||||
const [isFullScreen, setFullScreen] = useState(false);
|
const [isFullScreen, setFullScreen] = useState(false);
|
||||||
|
const [activeCell, setActiveCell] = useState(null);
|
||||||
const grid = useGridCore({
|
const grid = useGridCore({
|
||||||
data,
|
data,
|
||||||
serverMode,
|
serverMode,
|
||||||
@ -380,11 +381,14 @@ export default function PmsGrid({
|
|||||||
>
|
>
|
||||||
<div className=" d-flex justify-content-center align-items-center vh-50">
|
<div className=" d-flex justify-content-center align-items-center vh-50">
|
||||||
<div>
|
<div>
|
||||||
{loading ? (<p>Loading...</p>):(<img
|
{loading ? (
|
||||||
src="/img/illustrations/NoSearchResult.svg"
|
<p>Loading...</p>
|
||||||
alt="Image"
|
) : (
|
||||||
/>) }
|
<img
|
||||||
|
src="/img/illustrations/NoSearchResult.svg"
|
||||||
|
alt="Image"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
@ -523,11 +527,19 @@ export default function PmsGrid({
|
|||||||
<td
|
<td
|
||||||
key={col.key}
|
key={col.key}
|
||||||
style={style}
|
style={style}
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
setActiveCell({
|
||||||
|
rowId: row[rowKey],
|
||||||
|
columnKey: col.key,
|
||||||
|
});
|
||||||
|
col.onCellClick && col.onCellClick(row, col);
|
||||||
|
}}
|
||||||
className={`${col.className ?? ""} ${
|
className={`${col.className ?? ""} ${
|
||||||
col.pinned
|
col.pinned
|
||||||
? "pinned-left px-3 bg-white pms-grid td pinned"
|
? "pinned-left px-3 bg-white pms-grid td pinned"
|
||||||
: "px-3"
|
: "px-3"
|
||||||
}`}
|
} ${activeCell?.rowId == row.id && activeCell.columnKey === col.key ? "grid-cell-active" : ""} cursor-pointer`}
|
||||||
>
|
>
|
||||||
{col.render ? col.render(row) : row[col.key] ?? ""}
|
{col.render ? col.render(row) : row[col.key] ?? ""}
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@ -215,6 +215,12 @@
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
.grid-cell-active {
|
||||||
|
outline: 1px solid #696cff; /* Sneat primary */
|
||||||
|
outline-offset: -2px;
|
||||||
|
background-color: #f5f6ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user