GridEdit - How to show an icon for copying field value?

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
christ2000
User
Posts: 529

GridEdit - How to show an icon for copying field value?

Post 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


mobhar
User
Posts: 11905

Post 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.


christ2000
User
Posts: 529

Post by christ2000 »

i cant find the error, any help?


christ2000
User
Posts: 529

Post 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");
        }
    }
}

Post Reply