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
Here is how the drop-down works but alphabetically ordered
My attempt to order them differently
As you can see here
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
.
Best Answer
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:
table1_sort
- manual sorting of rows.table1_type
- groups.Table 2:
table2_sort
- manual sorting of rows.table2_type
- groups.table2_objects
- objects.table2_sort
- The field that contains the same values as thetable1_sort
field.New data will be entered in
Table 3
. It should contain the following fields:types
- groups.objects
- objects.Now go to
Table 3
field paramaters and set the Widget type toValue Relation
.Now select the
types
field and set the following parameters for it:Layer
->Table 1
Key column
->table1_sort
Value column
->table1_type
Now select the
objects
field and set the following parameters for it:Layer
->Table 2
Key column
->table2_sort
Value column
->table2_objects
Filter expression
->current_value('types') = "table1_sort"
Now you may try to enter your data with the Drop-down list (with manual sorting):
<== (click to watch)