I had no problem getting the export to Excel from XamDataGrid working. Your video and samples were perfect. But it always exports everything.
Is there any way to tell it to only export the selected records?
I did try to handle the DataPresenterExcelExporter.RecordExporting event and cancel if the record is not selected, but for some reason every record has IsSelected == false when this event is raised.
Thanks,
Mike
P.S.This is with 9.2 (WPF of course).
The record instances in the print/export grid are not the same as the record instances used by the display grid. The selection is not copied over during the print/export process. However, you can use the GetAssociatedRecord method to get the associated record from the display grid and check its state information.
Hi Michael,
The event you should use is the ExcelExporter.InitializeRecord. Then call e.Record.GetAssociatedRecord(). If this is not selected then the event args class expose various options for skiipping the record, its descendants, its siblings or to stop exporting completely.
That did it. I got it working properly today.
How do I export everything when nothing is selected, and export selected records when some rows are selected?
I'm not sure how your app is set up but the easiest thing would be to check the XamDataGrid's SelectedItems.Records.Count property. If it is zero then don't wire the InitializeRecord event