3.5.4. Customer Editor With a List of Orders
Do the following to display the list of Orders in the Customer’s edit screen:
-
Go to the GENERIC UI tab on the navigation panel. Choose
customer-edit.xml
screen and click Edit. -
Go to the DATASOURCES tab on the screen designer page and click New.
-
Select the newly created datasource in the list. Its attributes will appear in the right part of the page.
-
Specify
collectionDatasource
in the Type field. -
Select
Order
entity in the Entity list. -
The data source identifier −
ordersDs
- will be automatically generated in Id field. -
Select
_local
view in the View list. -
Add the WHERE clause to the query generated in the Query field:
select o from sales$Order o where o.customer.id = :ds$customerDs order by o.date
The query contains orders selection criterion with
ds$customerDs
parameter. The parameter value named likeds${datasource_name}
will contain id of the entity selected indatasource_name
datasource at the moment, in this case it is the id of the Customer being edited. -
Click Apply to save the changes.
-
Next go to the LAYOUT tab in the screen designer and find the
Label
component in the components palette. Drag this component to the screen components hierarchy panel and place it betweenfieldGroup
andwindowActions
. Go to the PROPERTIES tab on the properties panel. Enter the label valueOrders
in the value field.TipIf the application is intended to be used in multiple languages, use the button next to the value field to create the new message
msg://orders
and define label values in required languages. -
Drag
Table
from the components palette to components hierarchy panel and place it betweenlabel
andwindowActions
. Select this component in the hierarchy and specify table size in the PROPERTIES tab: set100%
in the width field and200px
in the height field. ChooseorderDs
from the list of available datasources. Then generate the table identifier using the button next to the id field:ordersTable
. -
Click OK on the top panel to save the changes in the screen.