K2BTools Tutorial - Exercise 7.5: Add custom code to the Events

In addition to generating the Web Form of web panels, K2BWebPanelDesigner generates basic code in the events for managing security, paging of all grids, loading of grids without base table, actions confirmation, etc.

To work with this tool, the developer must know that some areas are maintained by K2BTools, while others must be updated by the developer. In those areas the developer may add new code.

To see how this works in practical terms, go to the Events part and see all the events generated by K2BWebPanelDesigner. The rules are as follows:

  1. GX Standard Events (Start, Refresh, Grid.Load, etc) cannot be modified by the developer.
  2. Events and subroutines whose name starts with “E_” cannot be modified by the developer.
  3. Subroutines whose name starts with “U_” can be modified by the developer.

Now, you will add code to implement the “SelectCustomer” action created before. To do so, you must:

  1. Locate the “U_SelectCustomer” subroutine. Note that the “E_SelectCustomer” event is the event invoked by the button, but it is not editable by the developer. Tip: You can have a direct access to the event by using the GoToEvent action in the "SelectCustomer" node.
    Lesson7GoToEventAction
    Go to event action

  2. Add the following code to implement the action

&CustomerId_Filter = CustomerId

CustomerComponent.Object = Customer.Create(K2BTrnMode.Display, &CustomerId_Filter)

GridInvoice.Refresh()

U_SelectCustomer code

  1. In the first line, the “Customer” filter is updated to filter the invoices that are related to the selected customer.
  2. In the second line, the CustomerComponent is updated to show the Customer transaction in display mode (for the selected customer)
  3. In the third line, the Invoices grid is refreshed to show the invoices associated to the new customer.

The Web Panel is complete, you can execute it now to see it in action!