dynamic – How can I make a dataset with one element display with a header row?


I’m building a virtual lab exercise in Mathematica. As part of it, I’m using Dynamic to show the students’ lab dataset that they store in memory using a ClickPane. However, I’m running into a quirk of Mathematica’s default formatting that isn’t ideal.

Specifically: Mathematica displays Datasets differently when they contain one element (MM 12.0):

ds1 = Dataset({<|"a" -> 1, "b" -> 2|>})
ds2 = Dataset({<|"a" -> 1, "b" -> 2|>, <|"a" -> 2, "b" -> 76|>})

enter image description here

Is there a way to get Mathematica to display a one-element dataset like ds1 with the keys as a header row and the values as a data row, rather than in columns?

Ideally this would be deployable inside a Dynamic block, so that the displayed data tables would smoothly grow as the students “collected more data”. In other words, if we did code such as

Dynamic( (* something involving a variable ds *) )
ds = ds1;

and then

ds = ds2;

the Dynamic display would show a two-column table with a header row in both cases.