This is far from a hack, it's pretty much what it's for.
I'm guessing you're passing the wrong thing to toDataset
, but without the code all we can do is guess.
This should make a proper dataset:
data = self.parent.parent.getChild("TableOfThings")
headers = data[0].keys()
rows = [row.values() for row in data]
ds = system.dataset.toDataSet(headers, rows)
return ds
edit : one more thing... Be aware that saving results may have a performance cost.
I used to do this with alarm tables and whatnot. I stopped because of performance issues.
Now, for csv exports, I actually fetch the filters configuration from the table itself, then apply them in a queryStatus
or whatever the function is that corresponds to the concerned table.
The export itself might take longer than before, because I'm doing a query just for it, but the loading of the table itself is much smoother, and exports are actually quite rare.