Page 1 of 1
Change behavior of save button in Viewer
Posted: Tue Jun 15, 2010 5:21 pm
by meukoh
I need to use my own function to export the report data to XML because some clients use a different XML structure than the one outputed by Stimulsoft.
In the Viewer, when the user click Save -> XML File, choose a file name and location, then press Save, is there a way to interrupt the save event, cancel it and instead call my own function so I can create the XML file myself?
Thanks.
Change behavior of save button in Viewer
Posted: Wed Jun 16, 2010 4:51 am
by Andrew
Hello,
Could you, please clarify your issue. Do you want make your own export to xml on the base of our DataSet or do you want to realize it from scratch?
Thank you.
Change behavior of save button in Viewer
Posted: Wed Jun 16, 2010 8:46 am
by meukoh
I would prefer to realize it from scratch.
I only want to use the "Save -> XML File" button already in the viewer because adding other buttons would confuse the user.
Thank you.
Change behavior of save button in Viewer
Posted: Thu Jun 17, 2010 2:44 am
by Jan
Hello,
You can use ProcessExport event of StiViewerControl. Please add your own event handler to this event. Default event handler is:
Code: Select all
protected virtual void OnProcessExport(object sender)
{
StiExportService service = sender as StiExportService;
service.Export(CurrentReport, null, false);
}
You need add check for StiXmlExportService.
Thank you.
Change behavior of save button in Viewer
Posted: Fri Jun 18, 2010 3:56 pm
by meukoh
Thanks for this answer. This is my event handler:
Code: Select all
private void OnProcessExport(object sender, EventArgs e)
{
StiExportService service = sender as StiExportService;
if (service is StiXmlExportService)
{
MySaveToXml();
}
else
{
service.Export(_stiReport, null, false);
}
}
It works but I have a hard time getting Stimulsoft to use it.
I saw that my StiReport object have ViewerControl and ViewerForm properties but they are always null, and creating new StiViewerControl or StiViewerForm doesn't seem to work.
The only way I found for Stimulsoft to use my new handler is this:
Code: Select all
_stiReport.Show();
((StiViewerForm)StiViewerForm.ActiveForm).ViewerControl.ProcessExport += new EventHandler(OnProcessExport);
However this is bad since the ActiveForm is easy to change for the user and can lead to NullReferenceExceptions.
Is there another way to access the StiViewerControl and StiViewerForm objects used by my StiReport object to show the reports?
Thank you.
Change behavior of save button in Viewer
Posted: Mon Jun 21, 2010 12:30 am
by Jan
Hello,
You need create your own form with StiViewerControl to use this event of viewer.
Thank you.