How to display a multilevel collection in different list boxes!

Starting with 4D v17, the content of a multilevel collection can easily be displayed in different list boxes. Meaning that you can bind several list boxes to display nested details … without a single line of code! This can be achieved by simply using an object or a collection as the data source for another list box!

With the new list box collection type, the “Current item” and “Selected items” properties have been added. Keep in mind that the “Current item” property allows you to get an object, while the “Selected item” property returns a collection.

Let’s checkout a concrete example and see how we can display the results of a blood test!

Database example

What’s in?

At the first level, we have the patient’s name, the date of the exam, and the name of the doctor. Then, the results are classified by category. For each category, there is a list of tests with the result value, the min, the max, and the unit.

In terms of data structure, we have an object with some first-level attributes (i.e. firstname, lastname, etc.), as well as a collection of category objects. Then for each category object, we have a collection of test objects. To summarize:

  "lastname": "Beal",
  "firstname": "Estele",
  "results": [{
    "category": "Metabolic",
    "test": [
      { "name": "Albumin", "value": ... },
      { "name": ... }]
  }, {
    "category": "Lipoprotein",
    "test": [
      { "name": "HDL", "value": ...  },
      { "name": ... }]
  }, {...}]

The schema below describes how the results are displayed in two list boxes beside the object input. All this … without a single line of code! In fact, all properties are defined in the form objects, the only part where some coding is needed is when loading the result. That’s it, folks! ?


As you can see, this example makes blood test results easier to read and understand, especially when the incorrect data is highlighted with a splash of color.

To do this, we associated the following Decorate method with the meta expression in the list box property:

If (This.value>(This.max*2))
 If ((This.value>This.max) | (This.value<This.min))
 End if
End if

Vanessa Talbot
• Product Owner •Vanessa Talbot joined 4D Program team in June, 2014. As a Product Owner, she is in charge of writing the user stories then translating it to functional specifications. Her role is also to make sure that the feature implementation delivered is meeting the customer need.Since her arrival, she has worked to define key features in 4D. She has worked on most of preemptive multi-threading new features and also on a very complex subject: the new architecture for engined application. Vanessa has a degree from Telecom Saint-Etienne. She began her career at the Criminal Research Institute as a developer for the audiovisual department. She has also worked in media and medical fields as expert in technical support, production as well as documenting new features.