Thursday 13 October 2011

Crystal Reports: Drill Down Reports at One Level


Crystal Reports: Drill Down Reports at One Level

Drill Down Reports are among the powerful features available in Crystal Reports. If you have a simple report with one group, one series of subtotals, and some detail information, you can change it into a drill down report by setting "Hide" on Group Header 1 and the detail section.One thing that makes the drill down work better is to put the Group Name, or some other suitable caption into the group footer. That caption and the subtotals are what appear at the top level. When you drill down with a double click you get the Group Header, Details and Group Footer.
Drill down reports can be viewed and printed at the summary level, or a specific drill down, or any combination of these. They are a useful analysis tools for users at all levels.
Now, here's a twist.
A Chelseatech client wanted a report developed that had three groups (product group, product and customer) with a drill down to the lower level groups. The challenge was that the lowest level actually combined two fields: region and customer. They didn’t want a drill down or summary by region, but at the customer level they wanted customers sorted by region and then customer.
So we used a formula to combine the two fields (Region + Customer) and grouped by that. We customized to group name to display the customer name and placed the region field in the group 3 header.
We then set the conditional suppress on the Group 3 header to
DrillDownGroupLevel <>2 and {Table.Region} = Previous({Table.region})
The top two levels displayed as expected. When the third drill down processed, we got the header section with the region description to appear. This was exactly what the customer wanted.

Use DrillDownGroupLevel function in a formula for your page header
The other useful technique we used on that report was to use a formula for the page title. Inside the formula we used DrillDownGroupLevel to create a level specific heading:
If DrillDownGroupLevel = 0 then "Company Sales Report else
If DrillDownGroupLevel = 1 then "Product Sales: " + {Table.Product} else //etc.

Wednesday 12 October 2011

Generate dynamic ASP.NET pages by using XML and XSLT


Introduction

Sometimes you need to create dynamic pages. You may allow users to build their own applications by selecting the fields they need. In this article, I will show how to build dynamic applications by using ASP.NET and XML. In this example, I use XML for meta-programming or generative programming. I use XML with an XSLT to generate ASP.NET PRE, utilizing intrinsic ASP.NET parsing methods with the XSLT output. Steps that we need to do:
  • Create XML file (schema of our page).
  • Create an XSLT style to transform XML into ASP.NET PRE.
  • Transform XML, and create server controls defined by the generated ASP.NET PRE at runtime.
  • Insert the instantiated controls into the page's control collection.
  • Handle postback events from server controls.
Next step is to create XSLT style to transform our XML schema The XSLT iterates through each field, first outputting a label for the field as plain text. The stylesheet also checks if the field is required, and adds aRequiredFieldValidator if needed. The stylesheet then creates a Web Control (it could be any valid web control such as TextBoxRadioButtonListDropDownList, etc.). ListItems are created for each of the ListControls.



Conclusion

In this article, we separate data from content to make a cleaner design and for better maintainability. When XML is combined with XSLT, ASP.NET server controls become even more powerful. This opens up numerous possibilities fordynamic and robust systems.