Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

WPF End-User Report Designer - How to Implement a Report Storage

$
0
0

This example demonstrates how to implement report storage to persist report definitions in a database or in any other custom location. This enables your end-users to create and customize reports using the End-User Designer for WPF and have a common target for saving and sharing all reports. This functionality is accomplished through the DevExpress.Xpf.Reports.UserDesigner.IReportStorage interface. The interface provides the following methods:

• bool CanCreateNew();

Indicates whether or not it is possible to create a new tab with a blank report in the designer.

• bool CanOpen();

Indicates where or not the "Open" command is available.

• XtraReport CreateNew();

Provides the capability to customize a new report template.

• XtraReport CreateNewSubreport();

Provides the capability to customize a new subreport report template (i.e., a new report opened by double-clicking a specific XRSubreport control).

• string GetErrorMessage(Exception exception);

Provides the capability to display an error message for any encountered exception (a general one or the exception message if you expect that the user can understand and react based on this information).

• string Open(IReportDesignerUI designer);

This method expects a unique ID of the report selected by an end-user via a custom dialog.

• XtraReport Load(string reportID, IReportSerializer designerReportSerializer);

This method passes the report ID that has been selected at the previous step and expects the actual report instance to be loaded and returned. You may or may not use the IReportSerializer functionality to save or load a given report from a stream.

• string Save(string reportID, IReportProvider reportProvider, bool saveAs, string reportTitle, IReportDesignerUI designer);

This method is intended to save the currently edited reports. The method's parameters are:

- reportID is a unique ID of the edited report (null if it is a new report with no ID specified);

- reportProvider allows you to access the actual report instance being edited and optionally rename it (a new name will be updated in the designer as well);

- saveAs indicates which particular command has been executed ("Save" or "Save As").

- reportTitle represents the actual report title (the XtraReport.DisplayName property value).

- designer is the actual report designer instance (a DevExpress.Xpf.Reports.UserDesigner.ReportDesigner object).

 

See also: Report Storage for the WinForms End-User Report Designer.

Question Comments

Added By: Benjamin Hemken at: 6/30/2016 1:00:38 AM    This doesn't work as described in v2016 vol 1.4.  CreateNew() is never called since creating a new report with the WPF End-User-Designer always opens the Report Wizard.
Added By: Yaroslav (DevExpress Support) at: 6/30/2016 7:42:23 AM    

Hi Benjamin,
I also noticed this behavior. I took the liberty of extracting this issue into a separate thread created on your behalf and forwarded it to our R&D for further research: Opening a new report in the wizard doesn't invoke the IReportStorage.CreateNew method. We'll reply there ASAP, but please pardon any delay that may arise.
Thanks,
Yaroslav

Added By: Benjamin Hemken at: 7/4/2016 6:54:11 AM    No worries, after upgrading to 16.1.4.16179  I moved my logic from the ReportStorage's CreateNew() method to a new button in the ribbon bar (since adding new buttons is now easy as pie). In my case this is even a better solution because I previously used the CreateNew() method to open a custom wizard in a hackish way.

Still, I would rather replace the default report wizard with a custom one to save that additional button but it doesn't seem to be possible right now (according to this https://www.devexpress.com/Support/Center/Question/Details/T397389#comment-bbaf96d8-9117-426a-a5fc-9143b8fbd39f)
Added By: Yaroslav (DevExpress Support) at: 7/4/2016 11:04:34 AM    

Yes, Benjamin, it's true. Well, it's actually not about the possibility to create a custom ReportWizard (you already have one), but rather about overriding various designer context-menu commands and smart-tag verbs that still rely on the default behavior.  

Added By: René Lærke at: 10/6/2016 2:24:12 AM    Please consider changing the method: 
[C#]
publicstringOpen(IReportDesignerUIdesigner){StorageEditorFormform=CreateForm();form.Owner=Window.GetWindow(designerasDependencyObject);form.textBox1.IsEnabled=false;bool?result=form.ShowDialog();if(result.HasValue&&result.Value)return(string)form.textBox1.Tag;elsestring.Empty;// Culllpit return null instead}
to return "null" when no result is returned. Otherwise it will lead to clearing the "Report Source Url" when the user cancels "Edit..." on a sub-report.

Found the solution in T332177 but the below example should be corrected.Added By: Yaroslav (DevExpress Support) at: 10/6/2016 11:30:06 AM    

Hi René,
Thank you for drawing our attention to this matter. Yes, you're right, you can return null instead, but actually we've fixed that issue with returning the String.Empty value, so everything should work as expected in version 16.1.4 or higher. Can you confirm this or did I misunderstand your scenario?


Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>