Page 1 of 1
GridEdit - How to show an icon for copying field value?
Posted: Sun Jun 16, 2024 10:33 am
by christ2000
Hello i have the following code to show an icon next to the supervisor name to copy the name, the problem is the icon just appear on list page but no on edit, gridedit or add, here is the code
// Row Rendered event
function Row_Rendered()
{
// Apply list page specific styles
if ($this->PageID == "list") {
$this->meeting_duration->CellCssStyle = "text-align:center;";
$this->observed->CellCssStyle = "text-align:center;";
}
// Debugging output
error_log("PageID: " . $this->PageID);
error_log("CurrentAction: " . $this->CurrentAction);
// Add copy icon next to supervisor full name and credentials with color #1370c1 and align to the right
if ($this->PageID == "list" && ($this->CurrentAction == "gridedit" || $this->CurrentAction == "gridupdate" || $this->CurrentAction == "")) {
error_log("In GridEdit, GridUpdate, or List mode within List page");
if (!empty($this->supervisor->CurrentValue)) {
// Assuming the ViewValue contains the combined full name and credentials
$combinedValue = $this->supervisor->ViewValue;
error_log("Supervisor ViewValue before: " . $combinedValue);
// Update the ViewValue to include the copy icon
$this->supervisor->ViewValue = '<div style="display: flex; justify-content: space-between; align-items: center;">' . htmlspecialchars($combinedValue, ENT_QUOTES) . ' <i class="fas fa-copy copy-icon" style="cursor: pointer; color: #1370c1;" onclick="copyToClipboard(event, \'' . htmlspecialchars($combinedValue, ENT_QUOTES) . '\')" tabindex="0"></i></div>';
error_log("Supervisor ViewValue after: " . $this->supervisor->ViewValue);
} else {
error_log("Supervisor CurrentValue is empty");
}
}
}
any idea? thanks
Re: GridEdit - How to to show an icon to copy field value?
Posted: Sun Jun 16, 2024 2:02 pm
by mobhar
You may double check this condition:
if ($this->PageID == "list" && ($this->CurrentAction == "gridedit" || $this->CurrentAction == "gridupdate" || $this->CurrentAction == "")) {
since it does not handle for Add and Edit pages.
Re: GridEdit - How to show an icon for copying field value?
Posted: Mon Jun 17, 2024 10:11 pm
by christ2000
i cant find the error, any help?
Re: GridEdit - How to show an icon for copying field value?
Posted: Mon Jun 17, 2024 11:20 pm
by christ2000
i change to this but keep not showing on edit or add using gridadd or single add:
// Row Rendered event
function Row_Rendered()
{
// Apply list, edit, and add page specific styles
if ($this->PageID == "list" || $this->PageID == "edit" || $this->PageID == "add") {
$this->meeting_duration->CellCssStyle = "text-align:center;";
$this->observed->CellCssStyle = "text-align:center;";
}
// Debugging output
error_log("PageID: " . $this->PageID);
error_log("CurrentAction: " . $this->CurrentAction);
// Add copy icon next to supervisor full name and credentials with color #1370c1 and align to the right
if (($this->PageID == "list" || $this->PageID == "edit" || $this->PageID == "add") && ($this->CurrentAction == "gridedit" || $this->CurrentAction == "gridupdate" || $this->CurrentAction == "")) {
error_log("In GridEdit, GridUpdate, or List mode within List, Edit, or Add page");
if (!empty($this->supervisor->CurrentValue)) {
// Assuming the ViewValue contains the combined full name and credentials
$combinedValue = $this->supervisor->ViewValue;
error_log("Supervisor ViewValue before: " . $combinedValue);
// Update the ViewValue to include the copy icon
$this->supervisor->ViewValue = '<div style="display: flex; justify-content: space-between; align-items: center;">' . htmlspecialchars($combinedValue, ENT_QUOTES) . ' <i class="fas fa-copy copy-icon" style="cursor: pointer; color: #1370c1;" onclick="copyToClipboard(event, \'' . htmlspecialchars($combinedValue, ENT_QUOTES) . '\')" tabindex="0"></i></div>';
error_log("Supervisor ViewValue after: " . $this->supervisor->ViewValue);
} else {
error_log("Supervisor CurrentValue is empty");
}
}
}