I've got an interesting issue with the UltraWinGrid when exporting to Excel.
My data is an Invoice object from NHibernate with a HasMany collection of Detail records.
IF I bind my UltraWinGrid to a BindingSource and set the datasource of the BindingSource to a List<Invoice> and export the grid, I do NOT get any of the detail records, although I DO get an expansion indicator.
IF I bind my UltraWinGrid directly to the List<Invoice> and export the grid, I DO get the detail records exported.
This can be seen in the attached spreadsheets
If I handle the RowExporting event, I find the row that does NOT export the data has no columns in the detail band, while the one that does export properly has all the columns. Again, the only thing changing is the grid is bound to a binding source vs. binding directly to the data.
sdnewell said:I can see the child bands are NOT visible when loading the grid via the binding source and ARE visible when loading the grid directly from the List<Invoice>.
That's very odd. But whatever is happening there is clearly a problem with the BindingSource not returning the correct data. I've never heard of anything like that before, though. The BindingSource usually just wraps the data source you give it and doesn't alter the data structure as far as I know.
What's the Type of the property on the Invoice class that returns the child list?
Also... if you can, I recommend changing List<Invoice> to BindingList<Invoice>. List is really not a good class to use for data binding. BindingList has much better data binding support.
I had 'hidden' the child bands by overriding the expansion indicator to Never. By changing that back to Default, I can see the child bands are NOT visible when loading the grid via the binding source and ARE visible when loading the grid directly from the List<Invoice>.
I guess I'll go with the obvious solution, set the grid datasource to the List<Invoice> as opposed to a binding source.
Hi,
So... are you saying that the child records are showing up in the on-screen grid with the columns but that they simply do not export?
I don't see how that could be the case, unless something in your code is modifying the layout for exporting. The grid clones the layout for exporting, so if there are column on the screen, those same columns should be in the export layout.
I'm not familiar with NHibernate, so I suppose it's possible that something about it is causing the cloning of the grid layout to fail, but without a sample project demonstrating this behavior, I can only speculate.