4

I am using a geopackage with a number of tables, some of which I have added in a Value Map to the fields. The value map is to ensure consistent entry of codes to the data to comply with a specified schema by the client.

When editing via the Attribute Table, I would like to be able to flip between displaying either the "Value" or the "Description".

The reason is that if I have a few edits the drop-down list of "Descriptions" is handy. However, if I want to use the update bar at the top of the table to do a bulk edit (eg Update All), I can't recall the corresponding "values" and it creates errors if I get it incorrect.

Is there a way to flip the display of the attribute table so that it alternates between the two options (values or description)?

My usage is the creation of work as executed data. I convert the surveyors' information into GIS and then add attributes to it. Initially, I would do a "bulk" update of all bars (using the "values") to get the information say 90% correct, and then use the "Descriptions" to fine-tune the remaining features.

2 Answers 2

1

There are some options if you are prepared to use PyQGIS.

For example, you can capture the details of the Value Map in a variable and then switch the attribute form to a Range (ie values) using the following code:

vl = iface.activeLayer() # Assuming layer is selected
fld_idx = vl.fields().lookupField('Name') # Replace Name with your field
v_map = vl.editorWidgetSetup(fld_idx).config()
vl.setEditorWidgetSetup(fld_idx, QgsEditorWidgetSetup('Range',{}))

Assuming you are still in the same QGIS session, you can then switch the form back to the saved Value Map using the following code:

vl.setEditorWidgetSetup(fld_idx, QgsEditorWidgetSetup('ValueMap', v_map))

This adapts some code from: Use PyQGIS to load Value Map against attribute

0

You can make a column invisible by editing its widgets in Layer Properties > Attributes Form

More info: https://docs.qgis.org/testing/en/docs/user_manual/working_with_vector/vector_properties.html#edit-widgets

Your Answer

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

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