Consultor Eletrônico



Kbase 17598: Using choice-list and list-boxes as master-detail
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/05/1998
Using choice-list and list-boxes as master-detail

Using choice-list and List-boxes as master-detail relationship

The following kbase describes how choice-lists and list-boxes
can be used in a master-detail relationship. The choice-list
in this example is based on the Suppliers table in the Northwind
database and displays CompanyNames. Based on the value of the
choice-list, a list-box will display the ProductNames associated
with that Supplier from the Products table.

Create the following DataSources using a Northwind DataConnection
master: SELECT * FROM Suppliers
detail: SELECT * FROM Products
supp_prod: SELECT * FROM Supplier
Create a Data Relationship for supp_prod to detail:
supp_prod.SupplierID --> detail.SupplierID
Create the following LookupLists to use to populate the controls:
llmaster: DataSource = master Display column = CompanyName
Lookup Mode = dynamic Storage column = SupplierId
lldetail: DataSource = detail Display column = ProductName
Lookup Mode = dynamic Storage column = ProductID
Add a choice-list and list-box to the form.
Modify the properties of the choice-list as follows:
Columns: choose the master DataSource, column SupplierID
LookupLists choose Choice List, highlight llmaster
Modify the properties of the list-box as follows:
Columns: choose the detail DataSource, column ProductID
LookupLists choose Choice List, highlight lldetail

Add the following code to the Action event for the choice-list:

public void OnActionchoice1 (Object arg)
{
abForm form = null;
abI_Controllable control = null;
abDataSource ds = null;
AppletContext appletcontext = null;
ds = theApp().getDataSource("supp_prod");
if (ds != null)
try {
ds.setFilter("SupplierID = " + choice1.getValue());

} catch (Exception e)
{ System.out.println(e.toString()); }
return;
}

PES 01/22/98

Progress Software Technical Support Note # 17598