This content has been archived.

Table of Contents

Using the pxButton control rule

Summary

Introduced in V6.1 SP2, the auto-generated control rule pxButton is used in the Button control. This rule incorporates a large variety of pre-configured actions that are easily implemented in section, harness, and flow action rules, in both repeating and non-repeating layouts. The button can trigger:

  • Action types that were available in the V5.4+ button control and the pzGridAction gadget.
  • Actions in navigation rules (available from the navigation editor's Action tab on the Node Details window).
  • New actions such as launching a harness from a work object.

You configure the button's appearance and behavior using the control rule's Parameters dialog. The default settings represent the basic configuration. However, you need to specify what action will run when the user clicks the button in a work form. For example, you can configure the button to:

In addition, the Parameters dialog lets you:

  • Add a label, tooltip, or image
  • Define conditions that, when not true, disable or hide the button

Your edits apply only to the button within the context of the section that contains it and do not update the underlying pxButton rule. You can add any number of buttons to a section, each with its own look and function.

This article provides an example that shows you how to use the Parameters dialog to configure a button.

 

Suggested Approach

Assume that you want a user to be able to edit properties in a repeating list that contains stock price information. In this example, you will create buttons with these prerequisites:

  • Allow users to enter or delete items in the list.
  • Restrict these functions to users who are both administrators and hold the privilege to update a report in a specified application.
  • Display images that describe the buttons' function.

Do the following:

Set grid to inline edit mode

  1. Open the layout in the section that you want to update and display the wireframe.
  2. Click the magnifying glass icon () next to header in the Repeat Grid header to open the Repeat Grid properties panel.
  3. In the Edit Mode drop-down list, select Inline as shown here.

The displayed data appears in read-only mode. When the user double-clicks a row, the editable fields in that row display as editable.

Add the Button control to the layout

  1. From the Basics group, drag and drop the Button control into an action-area cell.

  1. Click the magnifying glass icon () next to the cell to open the button's Cell Properties panel.

  1. In the panel, select the magnifying glass icon () next to the Control field. This displays the Button control Parameters dialog, which contains the relevant fields from the pxButton rule form's Control tab.

Modify the button's appearance

  1. Enter the text Add in the Label field. (As a best practice, start the text with a verb). If the Localize? checkbox is selected on the harness or section rule's HTML tab, a SmartPrompt appears in the field. If you plan to localize the text, select a field value rule with pyButtonLabel as the second key part.
  2. Enter the text Add company name in the Tooltip field. If localization is enabled, select a field value rule with pyActionPrompt as the second key part.
  3. Click the magnifying glass icon () next to the Image field to open the Image Viewer. In this example, the file webwb/add.gif is selected.

Add security

  1. Select the Disabled Yes radio button. This displays the Disabled Condition field.
  2. Select the standard when rule named hasAdminRole in this field.
  3. Select the standard privilege rule named UpdateLimitedForm in the Privilege field. When you enter the privilege, the When Not Met field appears.
  4. Select Disable from the drop-down list. Here are the fields when completed.

A user can add an item who has both an administrator role and holds the privilege to access this harness (limited to the application defined in the rule). Otherwise, the button is disabled.

Define the action

  1. In the Behaviors area on the Parameters dialog, click the add row icon (). The Behavior dialog appears.
  2. Select Click from the Event drop-down list.

  1. Click the Select... menu in the Action section. An array of action categories appears.
  2. Select Handle List Items > Add Item.

The menus close and the Position field appears in the Behavior dialog.

  1. In the field, select Before in the drop-down list.
  2. Click OK to close the Behavior dialog. The Parameters dialog looks like this.

  1. Click OK to save your edits and close the Parameters dialog.
  2. Save the section.

Test your Button control

Before you begin, configure your operator access group so that the security settings evaluate to true. Run the flow that uses the section containing the grid.

  1. When the report appears, hover your mouse pointer over the button to display the tooltip. Click the button to display the new row (which appears at the top of the list).

  1. Select a row in the report and click the button again. The new row appears above the row you selected.

  1. Reconfigure your operator access group so that the security settings do not evaluate to true and test again. Clicking the button should not open a row.
  2. Add a Delete button using the same procedure described above. Modify the button label, tooltip, and image. For the action, use the Handle List Items > Delete Item menu item. Here is example of the finished button in the report.

You cannot use the pxButton control in a harness's bottom cell. Drag and drop the Button control from the Basics group and configure it using the V5.4+ configuration method. See How to configure a local action in a button (V5.4+ harness rules).

Suggest Edit

50% found this useful

Have a question? Get answers now.

Visit the Pega Support Community to ask questions, engage in discussions, and help others.