K2BTools Tutorial - Exercise 6.4: Adding 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 “Allow Selection” event you enabled before . To do so, you must:

  1. Locate the “U_OnLineActivate” subroutine. Tip: You can have a direct access to the event by using the GoToEvent action in the "GridCustomer" node.
    CustomerGridGoToEvent
    Go to event example

  2. Add the following code to implement the action

&Selected_CustomerId = CustomerId

WCCustomer.Object = Customer.Create(K2BTrnMode.Display, &Selected_CustomerId)

GridInvoice.Refresh()

U_SelectCustomer code

  1. In the first line, the "&Selected_CustomerId" is updated with the selected customer id.
  2. In the second line, the WCCustomer 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.

This is how the subroutine should look now:

OnLineActivateResult
OnLineActivate result