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

Web Report Designer - How to use the custom serializer class (IDataSerializer) to serialize the XPO data source to make it visible in the web report designer

$
0
0

This example demonstrates how to use the custom data source component serializer class that implements the IDataSerializer interface to serialize a report's data source component. This approach is actual when you are displaying a report that uses the data source component that cannot be serialized by the report (for example, XPCollection, DataSet (untyped), IList). The Web Report Designer stores only the report definition, so if the data source component is not serialized, this component cannot be restored on the callbacks. As a result, the designer's Field List and Preview will be empty.
Note that such data source components as SqlDataSourceEFDataSourceObjectDataSource and Typed DataSets are serialized out-of-the-box, so it is not necessary to use this approach in case of using these components.

Use the following steps to serialize your report's data source component:
1. Create a custom data source component serializer class that implements the IDataSerializer interface. Implement this interface's methods to save (in the Serialize method) and restore (in the Deserialize method) your data source component from the string.
2. Register your custom data source component serializer class when your application is started. For example, use the Application_Start event in the application's Global.asax.cs file for this purpose:

[C#]
protectedvoidApplication_Start(objectsender,EventArgse){SerializationService.RegisterSerializer(XPCollectionSerializer.NAME,newXPCollectionSerializer());}

3. Assign the custom data source component serializer name (that you have registered in the previous step) to your report as demonstrated below:

[C#]
XtraReportreport=newCategoriesReport();report.Extensions[SerializationService.Guid]=XPCollectionSerializer.NAME;

You should do that before opening you report in the Web report designer.


Important Note: This approach will work only for XML serialization. So, if you want to save the report along with the serialized DataSource, use the XtraReport.SaveLayoutToXml method to save the report's definition.


FAQ:
How to implement the custom serializer class (IDataSerializer) to serialize the DataSet data source?
Please refer to the to the following KB article to learn how to do that: How to serialize a report to XML with an untyped DataSet as a data source.


Viewing all articles
Browse latest Browse all 7205

Trending Articles



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