"Transposed" Data Grid?

Has anyone written/borrowed a Grid where the rows are fixed (with non-scrolling headers) and the columns repeat?

I have data that should be presented and edited in that orientation. The values that are related form a column, not a row.

The Horizontal Repeating Panel and 2D Repeating Panel could make parts of it, but it’s missing the Data Grid’s equivalent of “column” (actually row) definitions, which would be leveraged for each column.

I had done this before somewhere but could not find it. From my best recollection I just created a generator that pivoted the columns as it was read into the grid.
(My best analogy at the time was excel pivot tables)

This was bothering me so I recreated an example to make me feel less insane:
It isn’t exactly what you were asking for just how I was trying to figure out what I did before.

def pivot_generator(self, list_of_dicts):
  if not list_of_dicts:
    raise StopIteration
  for key in list_of_dicts[0].keys():
    yield {str(i):v for i,v in enumerate( (x[key] for x in list_of_dicts)  )}

https://anvil.works/build#clone:IVY2INK7PDQZXNWS=YP75BIXCKIFISV25MAFJTRSM

Yes, it’s been bothering me, too. Even Tabulator is built on the assumption that it’s the columns that are fixed.

I know I can hack something together. It’s just working against the grain of the existing components.

I wonder if Anvil Extras ‘Pivot’ component could help you here? I’ve not actually used it…

https://anvil-extras.readthedocs.io/en/latest/guides/components/pivot.html

1 Like

That’s a “pivot” of a different color :wink:. A quick skim indicates that it is for multi-dimensional aggregation, analysis, and plotting. That certainly has its uses, and I appreciate the link.

My case is much simpler. I’m just trying to simplify the code for column-wise data entry.