4

Looking for assistance to set up appropriate configuration to enable drop-down lists values to be filtered based on a previous value.

Basically, I have a 3-tiered categorisation structure to one of our GIS layers - Class > Type > Sub Type.

Once Class has been selected I would like the Type list to be filtered to only values relevant for that class and so on for Sub-Type.

enter image description here

I have turned this into Code Value list attribute tables and loaded inot QGIS as attribute tables -

enter image description here

I have used these tables as Value Relation lists in the widget properties

enter image description here

The drop down lists work fine without a filter. But as soon as I try adding a filter with an expression, there is nothing in my drop down... If I simply type "CLASS_ID" = 1 ... I do limit the list to only those for Class = 1. The expression on it's own (attribute($currentfeature, 'LU_CLASS') correctly populates the integer values if I use it to populate a virtual field in the expression builder...

Can anyone provide any guidance as to why this doesn't work in the widget filter?

I have also (briefly) tried to set up a relation in the project properties... but this feels like I am going about it the wrong way... the records aren't a child or related to this other table - I simply want to use them to populate drop-down lists.

Am I just missing a simple step?

  • Would this core feature already be what you want? gis.stackexchange.com/questions/156039/… – Matthias Kuhn Nov 17 '15 at 15:54
  • Hi Matthias, this other question was also posted by me (after I had little feedback on this one and did a bit more experimentation myself) - it kind-of works, but requires far more setup and overcomplicates what should be relatively simple. As I understand it, the "relation reference" is for true parent-child dependencies, such as a pole or feature that has multiple connections to it. The suggestion below of a "$currentformfeature" expression sounds great to me, and like it would make the above situation work. – Jamie Nov 17 '15 at 22:32
4

$currentfeature refers to the related layer (Type_Values in your example) so the expression always return false and all values are filtered out.

See: https://lists.osgeo.org/pipermail/qgis-developer/2015-November/040382.html

  • This sounds like a wonderful suggestion! Would be very keen to see this implemented so that the above workflow example would work :) – Jamie Nov 17 '15 at 22:48
4

I've just published a plugin that allows for drill-down and other complex filtering of values in a form, have a look:

http://www.itopen.it/a-new-qgis-plugin-allows-dynamic-filtering-of-values-in-forms/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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