Bug report #19458
Cannot permanently change order of columns in attribute table.
Status: | Closed | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | - | ||
Category: | Attribute table | ||
Affected QGIS version: | 2.18.19 | Regression?: | No |
Operating System: | Easy fix?: | No | |
Pull Request or Patch supplied: | No | Resolution: | invalid |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 27286 |
Description
The order of columns in attribute table (table view) cannot be altered. It is saved in a style .qml file, but you cannot alter it in layer properties. You can alter it with Refactor Fields, but then if you apply a previously saved .qml stylesheet file, it reverts the column order to the way it was before refactoring. You can control it in Form View via Properties\Fields tab, but not Table View, except for temporarily which only lasts until you close and re-open the table. I have to reconstruct the whole style from scratch on a refactored layer. This must be some sort of regression.
I am working with shapefile layers.
History
#1 Updated by Steve Lowman over 6 years ago
I guess you could reproduce it with these steps (something like):
1. Create shapefile layer with a few attribute columns in a certain order.
2. Save the style as .qml
3. Refactor the layer with a changed order of attribute fields.
4. Add the refactored layer and observe your changed order of fields is correctly changed in the order of Attribute Table columns (table view).
5. Load your saved .qml stylesheet file to the refactored layer.
6. Observe that the order of columns in Attribute Table (table view) has reverted to the original order, but in Layer Properties it remains unchanged.
7. Try to change that Attribute Table columns order (permanently) again without using the refactored version (I think only possible by editing QML in a text editor).
Now, after some thought, I am struggling with the process logic. QML controls the column order by the order of the <column> sub-elements grouped within the <attributetableconfig><columns> element. I think perhaps it is just wrong that the QML does anything to the order of columns without a way to change this part of the QML via Layer Properties. If the order can be controlled by refactoring, then why let the QML over-rule that? It means you cannot apply a previously saved style to the refactored layer without losing your changed order of columns, unless you edit the QML text directly, which many users will not understand or think to try.
In conclusion, either the QML should have no influence over attribute table column order, or it should be possible to amend the column order in Layer Properties.
#2 Updated by Steve Lowman over 6 years ago
My first comment (below) seemed consistent with my experience of fixing one layer.
However, yesterday with a different layer, and now in QGIS 2.18.22, I tried to fix the column order by amending the .qml code, and it had no effect.
So, as a last resort, I then tried amending the column order in the Attribute Table itself, which I have previously found to have only a temporary effect, but this time the change stuck, so it seemed to be a permanent fix.
So, I end up being unsure how column order is meant to be controlled, but at least happy that I was able to amend it one way or another.
If this is not a bug, I would appreciate if there is any relevant advice or link to documentation that can be added as further comment here.
#3 Updated by Giovanni Manghi over 6 years ago
Steve Lowman wrote:
My first comment (below) seemed consistent with my experience of fixing one layer.
However, yesterday with a different layer, and now in QGIS 2.18.22, I tried to fix the column order by amending the .qml code, and it had no effect.
So, as a last resort, I then tried amending the column order in the Attribute Table itself, which I have previously found to have only a temporary effect, but this time the change stuck, so it seemed to be a permanent fix.
So, I end up being unsure how column order is meant to be controlled, but at least happy that I was able to amend it one way or another.
If this is not a bug, I would appreciate if there is any relevant advice or link to documentation that can be added as further comment here.
both ways are supposed to only have an effect within the/a QGIS project. If you want to physically change the order of columns in a shapefile you must use other tools, like the refactoring Processing tool or the table manager plugin.
#4 Updated by Giovanni Manghi over 6 years ago
- Status changed from Open to Feedback
#5 Updated by Alessandro Pasotti almost 6 years ago
- Resolution set to invalid
- Status changed from Feedback to Closed