Change table content when changing dropdown menu selection


I am currently working on an app in which the user can edit gefs (as part of the functionality of the app). I have constructed this in such a way where the user first selects a gef from a dropdown menu, then presses a button to enter the soil layout corresponding to that gef in a table, then the user can edit this table and save the changes with another button (the interface is shown below).

For CPTs the table shows each top_of_layer and the soil_type. For Boreholes the table shows each top_of_layer, the original interpretation and a third column with a soil type from table 2b from the NEN9997.

Interface when CPT selected:

Interface when Borehole selected:

Because the two tables have different columns I have created two tables and set their visibilities to True or False depending on the type of the selected gef (CPT or Borehole).

This leads to the following problem:
Let’s say I have three gefs, two CPTs (02535.01.17_S01.gef and AAHPT_MPT03.gef) and one Borehole (B38C0198.gef). I select one CPT first and click select gef in order to fill the table, the CPT version of the table is now visible and the table is filled out:

If I then switch my gef selection to the Borehole gef, the CPT version of the table gets hidden and the Borehole version of the table is shown:

After pressing select gef the table is filled out:

However, if I now select the third gef which is a CPT but different from the CPT that was selected at the start the CPT version of the table becomes visible again but because it has been filled out before it is not empty but contains values

Comparing this figure and the figure 3 figures up it can be seen that the selected gef is different but the contents of the table are the same. If I press the select gef button the table will be updated to show the soil layout corresponding to the newly selected gef. However, it can be confusing to the user because intuitively you would think that since the table is filled out the contents match the selected gef.

Because of this my question is if it is possible to update the contents of a table upon making a different selection in a dropdown menu (that way I don’t need to select gef button and can just immediately update the visibility and the content of the table)

Hi Rutger,

Thanks for this clear description of your case. To make sure I understand you correctly: you would like an action to be performed that changes (a subset of) the parameters based on changing a value (in this case the field “Selecteer GEF”), right?

The platform currently only allows changes to parameters through means of either the SetParamsButton (which you currently do by asking the user to click on the “Kies gef” button), or through the api functionality set_entity_params. The latter is only advised for changing parameters outside the current editor. Therefore, it is currently not possible to do this as you described.

There is, however, an alternative approach. You could define logic that does checks on conditions based on logic you define, and if it violates these conditions, a message is presented to the user that it fails the conditions specified (a message you define). For more info on this, refer to this link.

Let me know if this helps.

Hi Marcel,

Yes, you are understanding me correctly. VSCode shows that the parametrization class is called whenever a change is made in the parametrization on the VIKTOR web app. I was thinking about fiddling around with the default_content option for a table but this default_content can of course not be variable.

Maybe it would be a suggestion to allow the user to enter a function name in the Table() class by using a ‘content’ argument or something, similar to how it is possible to add a function name for the visibility of any field. If a function is given in the ‘content’ argument this function will be called any time the parametrization is called and will set the table content dynamically.

Hi Rutger,

Thank you for the suggestion. I’ve communicated this as a proposed solution to the issue of allowing dynamic defaults.

1 Like