Wednesday, December 9, 2009
Custom RDLC Reports for AJAX Web Apps

Data Aquarium Framework automatically creates RDLC reports in WYSIWYG style at runtime for any data grid views and replicates sort order and filters specified by the end users.

Try it live at http://dev.codeontime.com/demo/websitefactory1/pages/products.aspx.

You can quickly create custom reports that have the same behavioral properties.

Custom RDLC Reports for AJAX Web Apps (Data Aquarium Framework)

Watch this video on our YouTube channel at http://www.youtube.com/user/codeontime#p/u/5/Gli45vikyOU.

The Framework automatically creates in-memory report definitions by applying standard ~/Reports/Template.xslt stylesheet to XML data controllers of your application at runtime when a user requests a report.  Such reports are created in RDLC format. RDLC is the technology available in Microsoft Reporting Services, a component of Microsoft SQL Server.

Learn more about Microsoft Reporting Services:
http://www.amazon.com/gp/search?ie=UTF8&tag=ie8search-20&index=blended&linkCode=qs&camp=1789&creative=9325&keywords=reporting+services+2008.

First, the Framework creates a System.Data.DataTable class instance and populates it with the data displayed in the grid with filters and sort order applied. Next, the instance of Microsoft.Reporting.WebForms.LocalReport class is created and supplied with the report definition, data table, and output format. The instance of this object will render the actual report file.

The code of the report engine that performs these steps is in ~/Report.ashx file in the root of project created by Code OnTime Generator.

The custom report option in the video can be also defined without Code OnTime Designer as shown in the snippet of ~/Controllers/Products.xml data controller.

<actionGroup id="ag7" scope="ActionBar" headerText="Report">
  <action id="a1" commandName="ReportAsPdf" headerText="PDF Document" 
        description="View items as Adobe PDF document.&lt;br/&gt;Requires a compatible reader." />
  <action id="a2" commandName="ReportAsImage" headerText="Multipage Image" 
        description="View items as a multipage TIFF image." />
  <action id="a3" commandName="ReportAsExcel" headerText="Spreadsheet" 
        description="View items in a formatted&lt;br/&gt;Microsoft Excel spreadsheet." />
  <action id="a100" commandName="ReportAsPdf" commandArgument="Products.rdlc" headerText="Custom Products Report" causesValidation="true" 
        description="This is a custom report" />
</actionGroup>

If the command argument does not include path information then the framework makes an assumption that the report is in ~/Reports folder. You can store reports in any other location under the root of your website. Just make sure that the relative path of the report is included along with the report name (for example, ~/MyLocation/MyFolder/MyReport.rdlc).

You can also customize the standard ~/Reports/Template.xslt and create alternative automatic templates. If the XSLT stylesheet name is specified as a command argument of action then Data Aquarium Framework will attempt to create a report definition on the fly using your custom stylesheet and then proceed with rendering of report in the specified output format.