[Qgis-developer] drill down in QgsValueRelationWidgetWrapper::createCache

Alessandro Pasotti apasotti at gmail.com
Tue Nov 17 12:08:43 PST 2015


2015-11-17 20:19 GMT+01:00 Nyall Dawson <nyall.dawson at gmail.com>:

>
> On 17 Nov 2015 10:56 PM, "Alessandro Pasotti" <apasotti at gmail.com> wrote:
> >
> > Hi,
> >
> > it seems that the widget's expression context does not have access to
> the currently edited record.
> >
> > Maybe I've just not found a way to do that but it's impossible to filter
> relations with an expression built upon the the values of the "main" record
> (the one currently edited in the form) because $currentfeature refers to
> the relation layer,
> >
> > A possible solution would be to add a $currentformfeature to the
> expression and add the edited feature to the expression context.
> >
> > Would it be a possible solution?
> > Any hint?
>
> I can't find the original discussion this relates too... What's the issue
> you're trying to solve?
>
> Nyall
>
>

Hi,

when using QgsValueRelationWidget I would like to be able to filter the
related items on the value from another column in the currently edited
feature.

I need an expression in the related layer which is based on a value in the
current feature, but in the context of the related layer $currentfeature is
not the feature currently being edited but the related feature.

So, we need to pass the feature or the feature ID to the widget or (better)
to the context, which is currently non possible since the call to
QgsValueRelationWidgetFactory::createCache populates the combo on widget
init and cannot be changed.

A possible solution is to add the currently edited feature informations to
the context (currentFeatureContext or something similar) and then retrieve
the feature information with $currentformfeature or the like.


Suggestions welcome!


-- 
Alessandro Pasotti
w3:   www.itopen.it
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20151117/33f277d2/attachment.html>


More information about the Qgis-developer mailing list