Actions - Grid Objects

WorkWithPlus has two kinds of actions: Standard Actions and User Action. Standard Actions are predefined actions to add out of the box features. The User Actions are actions that the developer will be able to codify in order to develop a custom behaviour.

Standard Actions: The Challenge

The customer needs to edit the information of a person, without opening the transaction, right from the grid. In order to do this, the transaction must be a Business Component, so make this configuration and save the transaction.

SelectionFeatures_img10

As the user also needs to keep the PersonWW where they have the option to insert and edit, from the Transaction form, we're going to create an ExtraSelection.

SelectionFeatures_img11

SelectionFeatures_img12

Assign the property ‘Name’ of the ExtraSelection node with the value ‘EditInGrid’ and the description that you would like to visualize in the "Developer Menu". Change the property ‘In Line’ of the actions Insert, Update and Delete to True.

SelectionFeatures_img13

Hide the column PersonId and configure the grid, so that it displays the following columns (and delete the rest of the columns):

  • PersonFirstName
  • PersonLastName
  • PersonNickName
  • PersonGender
  • PersonHobby

SelectionFeatures_img14

Run the application (F5) and navigate to the created object in order to visualize the results. You can test the new feature by modifying and deleting a record within the grid.

SelectionFeatures_img13.1

User Actions: The Challenge 

At runtime, navigate to the Companies´default list, select a record that do not have persons associated to it, and delete it.  The name of this Standard Action is 'Delete'.

SelectionFeatures_img24

It is desired that when the button to delete records is pressed, the application shows a confirmation message and in case the user confirms the action, directly deletes the record (without calling the transaction in delete mode).

To achieve this, we cannot use the StandardAction ‘Delete’ as it has a predefined behaviour. So, we'll need to codify a new action with our desired behaviour. To do this, we're going to create a new User Action.

SelectionFeatures_img25

Because of the database’s integrity validations, it is possible to delete companies only when the company does not have associated persons. In case someone tries to delete the company with persons, the system should show an error message, or directly restrict the deletion of those companies. To solve this, insert the action inside the grid and add a condition that analyses if the company has associated persons and enables or disables the action for every record of the grid.

To develop the feature is necessary to use two procedures: DeleteCompany and CompanyCanBeDeleted. These procedures are already imported in your KB.

SelectionFeatures_img26

The behaviour that analyses if a company has associated persons it developed in the procedure CompanyCanBeDeleted. We´re going to call this procedure in the new User Action. Then, assign the property GXObject of the action with the procedure DeleteCompany and add the correspondent parameter:

SelectionFeatures_img27

The event associated to the action is ‘DoUDelete’. This opens the confirmation panel, and in case the user confirms the action, it calls the sub ‘Do UDelete’. In the sub ‘DoUDelete’ it calls the procedure that deletes the record (assigned in the GXObject)

SelectionFeatures_img28

Execute the application and visualize the results.

SelectionFeatures_img29

Comments & Tips: remember that WorkWithPlus let you codify your events directly from the "Event" section of the generated Web Panel. You should have in mind that your code should be added before or below the automatic code added by WorkWithPlus.

Multi Row Selection: The Challenge

In the PersonContact’s default list, the customer requires selecting multiple contacts to delete them at the same time. To achieve this, the user actions have a property called "Multi Row Selection".

So, create a new User Action outside the grid, name it ‘DeleteSelected’ and assign the "Multi Row Selection" property to "True". The property 'Multi row select all' is used to add a 'Select all' checkbox to the multi-row selection column title. Assign"True" to this property also.

SelectionFeatures_img31

Save the instance. As you can see, WorkWithPlus has created an SDT with the information in the grid.

SelectionFeatures_img32

When the user presses the User Actions subroutine will be invoked, this subroutine will upload the selected records in a variable based on the SDT shown before.

From the instance you can right-click ‘Go to event’ to add behaviour to that action.

SelectionFeatures_img33

In the event 'DoDeleteSelected' insert the following code, below the code generated automatically by WorkWithPlus:

If &SelectedRows.Count > 0
    For &SelectedRow in &SelectedRows
        msg('Logical delete of contact ' + &SelectedRow.PersonContactName.ToString() + " of Person " + &SelectedRow.PersonFullName)
    EndFor
EndIf

Run the application and test the action created (do not select any company and press the action, then select some companies and press the action).

SelectionFeatures_img35

Summary

Well done! You should now be able to:

  • Identify the Standard Actions from the User Action
  • Add In-Line edition for your inserts, updates and deletes
  • Add and codify a new User Action
  • Add a new User Action with Multi-Row Selection