Evolutility.org 4.1
 

Dependent fields (AJAX)

This feature allows to make one field dependent of another (for dropdown fields - type "List of Value"). That way selecting a value in one list will automatically change the list of possible values in another list.

As a simple examples of dependent dropdowns we will use lists of countries and cities. Selecting a country limits the possible selection of cities to cities belonging to this country (as in this live example).


 

How it works

In our example, selecting a country triggers an AJAX call getting the new list of cities from the server and updating the dropdown on the form. The server call is replied by Evolutility.DataServer, a new assembly for a httpHandler.

Note: hard-coded for now, this assembly need to be modified for new lists of values will change in the next versions to become metadata-driven like the rest of Evolutility.

Adding dependencies

To setup a dependency between 2 fields, you must add to the master field the attribute dependency to specify the slave field (identified by its dbcolumn value).

In the XML

<field type="text" label="Name" ...
<field type="lov" label="Country" dependency="CityID"
dbcolumn="CountryID" dbcolumnread="Country" dbtablelov="dep_Country" ... />
<field type="lov" label="City" dbcolumn="CityID" dbcolumnread="City" dbtablelov="dep_City" ... />

Custom dependencies with Javascript

For total control over the behavior, it is possible to specify the name of the JavaScript method called when a value is selected in the master list. This is done in the metadata with the attribute jsdependency. Both dependency and jsdependency should not be used at the same time the same field.

In the XML

<field type="lov" label="Country" jsdependency="DoSomethingToTheUI" .../>