6

I have some attributes in my data and want to enable the user to pick values from drop-down lists. The values of the drop-down list change depending on the chosen value of the previous field(s). The values for the drop-down come from different domain tables.

The task I can accomplish perfectly with Value Relation Widget. However, it works only when I choose the same attribute "Key column" and Value Column. When I do that, I can only sort the drop-down alphabetically. In my domain table, I have a column for sorting and I would like to use that. When I choose that column then the hierarchy won't work anymore.

So it works if it is set like this

enter image description here

enter image description here

Here is how the drop-down works but alphabetically ordered

https://i.sstatic.net/MQsAc.gif

My attempt to order them differently

enter image description here

enter image description here

As you can see here

https://i.sstatic.net/nrb1q.gif

the values for L_PZART_KTG is sorted by SORT attribute, but the hierarchy won't work anymore. Nothing will be listed for L_GZGRP_KTG.

1 Answer 1

3
+50

Due to the fact that I am poorly versed in German - I created a separate data set in English, which should be understandable to all readers of the site.

In order to sort the data in the QGIS drop-down list according to a manually defined order, you need to have the following fields in the tables.

Table 1:

  1. table1_sort - manual sorting of rows.
  2. table1_type - groups.

Table 2:

  1. table2_sort - manual sorting of rows.
  2. table2_type - groups.
  3. table2_objects - objects.
  4. table2_sort - The field that contains the same values as the table1_sort field.

New data will be entered in Table 3. It should contain the following fields:

  1. types - groups.
  2. objects - objects.

Now go to Table 3 field paramaters and set the Widget type to Value Relation.

Now select the types field and set the following parameters for it:

  1. Layer -> Table 1
  2. Key column -> table1_sort
  3. Value column -> table1_type

Now select the objects field and set the following parameters for it:

  1. Layer -> Table 2
  2. Key column -> table2_sort
  3. Value column -> table2_objects
  4. Filter expression -> current_value('types') = "table1_sort"

Now you may try to enter your data with the Drop-down list (with manual sorting):

enter image description here <== (click to watch)

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.