views:

23

answers:

1

I'm trying to export an AdvancedDataGrid to CSV. This is easy enough for non-hierarchical data, but when using a HierarchicalCollectionView to show treed data it gets trickier.

Any suggestions on how to access each of the cells just as they appear on screen when all of the nodes are expanded?

A: 

Hierarchical data doesn't map well to CSV which is essentially flat. You are essentially trying to write nested objects into spreadsheet.

Accessing the data isn't that hard, you can just recursively work through getChildren() in the collection.

The hard bit is writing it into the CSV file in a way that can be retrieved later. The only really good ways of doing this is by ignoring the fact that you are writing to CSV. As soon as you get to the children field of the root object you are going to end up writing some horrible array parsing mechanism.

My solution? Write it out to JSON, and stick it in a single cell of the CSV. You'll save yourself a ridiculous amount of pain in the long run.

Gregor Kiddie
Yeah, but nested objects can easily be normalized into a table by just prefixing their parent nodes in each row. I've done it by traversing the data model, but this means that the appropriate column renderer isn't being called.
Senior