DynamicCombos

Unofficial Content

Linked combo or list boxes

Scope

Languages: Java, .NET, .NET Mobile
Objects: Transactions, Work Panels, Web Panels
Controls: Dynamic ListBox, Dynamic ComboBox,
Interfaces: Win, Web

Introduction

Creating friendly user interfaces is one of the main challenges faced by developers today, as modern applications require increasingly sophisticated data entry features. Among other things, an application's usability depends on how easy it is for users to enter data.

In this context, some scenarios that were difficult to implement when coding by hand can now be easily implemented with GeneXus .

The most typical example is the Country and City combo boxes, where the City combo box must show the cities of the country selected in the Country combo box.

Description

Example

if you have the following:

 

DynamicCombos01

 

DynamicCombos02

 

DynamicCombos03

The result will be as follows:
 

DynamicCombos04

The cities displayed match the selected country.

The navigation shows the following:

FILL CityID with CityID, CityName in 
      =CITY( CityID, CountryID) INTO CityName CityID 
Where CountryID = CountryID
Order CityName 
 

In general, if we have the following structure:
 

A*
A1

A*
B*
B1

One combo box defined in B depends on the value selected in A, in a transaction containing A and B.

In some cases, tables are defined as follows:

Trn: Country
CountryCod*
CountryName

Trn. City
CityCod*
CountyCod
CityName

In this case, we can't use the automatic filter function in dynamic combo boxes because the country is inferred from the city, and it isn't editable.
 

Compatibility

In some cases, Dynamic Combos that worked fine can change their behavior. The problem is that combos with subtypes aren't well defined.
For example:
 

CustomerCod*
CustomerNam

SalesCustomerCod
SalesCustomerNam
Customer Subtypes

SalesCod*
SalesCustomerCod -> Dynamic Combo (SalesCustomerCod, SalesCustomerNam)

 

The dynamic combo should be based on the supertype (CustomerCod, CustomerNam) and not on the subtype (SalesCustomerCod, SalesCustomerNam).

Note of compatibility (IsValid event triggering): Since GeneXus 9.0, Win applications have a different moment in which the IsValid event is triggered, depending on the control. For the Edit controls the IsValid event is triggered when exiting de field (as in GeneXus 8.0 and previous versions). For checkboxs, listboxs, combos and radiobuttons, this event is triggered when a value is selected in the control.

Condition

Being able to define the conditional load of a combo box is a great advantage. For this reason, we have a new property called Condition.

Example:

Suppose that you need a web panel or work panel to behave as a transaction. To do so, you can add variables based on CountryID and CityID, defined as dynamic combos, and define &CityID by country.

DynamicCombos05

Instantiated Attributes

Sometimes, a dynamic combo box can load records depending on other attributes, when there aren't any direct relationships. In this case we can use the new property called "Instantiated Attributes."

Example:

In a multi-company system we have a table with all products, and another table with all the products that the company can sell. For that reason if we have a products combo box, we can only see the products of the instantiated company.

Consider the following transaction:
 

DynamicCombos06

And the following relationship:

DynamicCombos07

If we define Product as a Dynamic Combo, we need to see the instantiated company's products. This isn't the default behavior.

 

DynamicCombos08

To define that the products are only those that the company can sell, we must indicate it in the new property "Instantiated Attributes."

DynamicCombos09

The navigation is as follows:

FILL ProductID with ProductID, ProductName in 
    =ENTPROD( ProductID, CompanyID) INTO ProductID CompanyID
    =PRODUCT( ProductID) INTO ProductName 

     Where CompanyID = CompanyID
     Order ProductName 

 

Empty Item

The Empty Item check allow to define an empty value. In general case we use this to describe the combo (i.e. "Select a Country").

DynamicCombos10

Attachment

Interesting Links

Official 'GeneXus and Ajax' site

Sample to see ajax features running online

More information about AJAX