# How to keep insertion order in the Spreadsheet table columns?

**URL:** https://discourse.paraview.org/t/how-to-keep-insertion-order-in-the-spreadsheet-table-columns/17638
**Category:** Development
**Tags:** python
**Created:** [June 29, 2026, 9:17am UTC](https://discourse.paraview.org/t/how-to-keep-insertion-order-in-the-spreadsheet-table-columns/17638 "2026-06-29T09:17:07Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![CsatiZoltan](https://discourse.paraview.org/user_avatar/discourse.paraview.org/csatizoltan/32/6997_2.png) [@CsatiZoltan](https://discourse.paraview.org/u/CsatiZoltan)
#### Post date: [June 29, 2026, 9:17am UTC](https://discourse.paraview.org/t/how-to-keep-insertion-order-in-the-spreadsheet-table-columns/17638/1 "2026-06-29T09:17:07Z")

</div>

In the `RequestData` method of my Python plugin, I fill a `VTKTable` by columns: one column for each dataset:

```python
from vtkmodules.numpy_interface import dataset_adapter

def RequestData(self, request, inInfoVector, outInfoVector):
    output = dataset_adapter.WrapDataObject(vtkTable.GetData(outInfoVector, 0))
    # my_data is a dict for dataset name - dataset value mapping
    for field_name, field_values in my_data.items():
        output.FieldData.append(field_values, field_name)
    return 1

```

The problem is that the order in which I add the fields is not conserved in the SpreadSheet View: they are reordered alphabetically. How can I tell the SpreadSheet View to respect the insertion order?

---

<div class="post-metadata">

### Author: ![dcthomp](https://discourse.paraview.org/user_avatar/discourse.paraview.org/dcthomp/32/20_2.png) [@dcthomp](https://discourse.paraview.org/u/dcthomp)
#### Post date: [June 29, 2026, 12:50pm UTC](https://discourse.paraview.org/t/how-to-keep-insertion-order-in-the-spreadsheet-table-columns/17638/2 "2026-06-29T12:50:34Z")

</div>

It appears to be [explicitly disabled here](https://gitlab.kitware.com/paraview/paraview/-/blob/master/Qt/Core/pqSpreadSheetViewWidget.cxx#L71). Enabling it allows me to drag columns around without issue, so I’m not sure why it is disabled.

Until it is enabled, there’s no way to programmatically reorder columns (as opposed to users choosing the order) either. Once it is enabled, [this explains](https://stackoverflow.com/questions/28074194/how-to-re-arrange-qtableviews-columns-order) how the column order might be set up programmatically.

I agree it would be nice if filters could provide hints for preferred column orderings and visibility; the UI could provide a combo-box for resetting things to different choices (alphabetical, insertion order, filter suggestions, user “saves,” etc.). But first, we would need to understand if there was a technical reason column reordering was forced off.

---

<div class="post-metadata">

### Author: ![CsatiZoltan](https://discourse.paraview.org/user_avatar/discourse.paraview.org/csatizoltan/32/6997_2.png) [@CsatiZoltan](https://discourse.paraview.org/u/CsatiZoltan)
#### Post date: [June 29, 2026, 1:20pm UTC](https://discourse.paraview.org/t/how-to-keep-insertion-order-in-the-spreadsheet-table-columns/17638/3 "2026-06-29T13:20:03Z")

</div>

Then it explains why I got the same behaviour with the built-in CSV reader of ParaView.

> Once it is enabled, [this explains](https://stackoverflow.com/questions/28074194/how-to-re-arrange-qtableviews-columns-order) how the column order might be set up programmatically.

I would rather prefer that there was a built-in option in ParaView, like `sorting`, that enables the user to choose alphabetical sorting, no sorting (i.e. insertion order conserved), etc. Otherwise, one would have to build ParaView himself and adding PySide6 (or whatever Python Qt bindings are supported in ParaView).

Why is this feature important in my opinion? Because some field data (columns in the SpreadSheet View) are more important than others in domain-specific applications. So it makes sense to me to let the user provide the more relevant columns first.
