Forums: Enable and Disable "inserted button" based on field's value on Grid - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Enable and Disable "inserted button" based on field's value on Grid phpr v 10.1

#1 User is offline   acpan 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 212
  • Joined: 05-October 07

Posted 06 May 2019 - 04:14 PM

Note: The topic should be: Show and Hide "inserted button" based on field's value on Grid

Assuming you have inserted custom button (email_reminder_button) on the grid:

Cust_ID | Cust_Name | Email | Account_Balance | email_reminder_button

Custom button codes - "Client Before", "Server" and "Client After" codes will execute the email sending, we will just focus on
how to show and hide the custom button based on the account_balance value on each row of the Grid.

1. Go to PHPR Designer Page.

2. Select the custom button inserted on the grid by clicking on it once.
Then on the right panel, click the ? mark on the right of "item_id" to popup a note page that explains how to use the codes.

3. Since i need to handle the custom button on the grid, i copy the following from the notes and paste to the after record processed event:
$pageObject->hideItem("email_reminder_button", $recordId);
$pageObject->showItem("email_reminder_button", $recordId);

Note: there is no need to edit anything, just copy and paste as the notes will automatically grab the right ID for you.

4. At the after record processed event, i can now conditioanlly hide and show the custom button based on the row data values:

// for troubleshooting, echo the row's data (values in the database for the row):
// (disable on production).

echo json_encode($data);

$account_balance = $data["account_balance"];

if ( $account_balance < 120 )
{
$pageObject->showItem("email_reminder_button", $recordId);
}
else
{
$pageObject->hideItem("email_reminder_button", $recordId);
}

5. That's all, the custom buttons will now show and hide based on its row values on list page.
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users