This is a migrated thread and some comments may be shown as answers.

Challenging layout!

1 Answer 110 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Groupe CDGI
Top achievements
Rank 1
Groupe CDGI asked on 02 Apr 2009, 07:06 PM
I'm anxious to ditch Crystal Reports and start working with Telerik in production but i first need to convert all my reports to Telerik. Problem is, i had some wacky reports but i'm sure there is a way to reproduce them. See the pic below before moving on :

http://s734.photobucket.com/albums/ww342/crazycoders/?action=view&current=crystallayout2.jpg

This layout, although it looks like it's displayed horizontally is actually displayed vertically like any other reports, but what we used was to simply detect group changes based on the employee name and service name and in the details section we'd hide the field that gets repeated for nothing.

In Telerik, i though i could achieve this doing the following: (Note that PreviousEmployeeName and PreviousServiceName as simple Strings declared private at the top of the report object)

    Private Sub Details_ItemDataBound(ByVal sender As ObjectByVal e As System.EventArgs) Handles Details.ItemDataBound 
        If PreviousEmployeeName = "" Or PreviousEmployeeName <> EmployeeName.Value Then 
            PreviousEmployeeName = EmployeeName.Value 
            PreviousServiceName = "" 
        Else 
            EmployeeName.Value = "" 
        End If 
    End Sub 
 
    Private Sub ServiceName_ItemDataBound(ByVal sender As ObjectByVal e As System.EventArgs) Handles ServiceName.ItemDataBound 
        If PreviousServiceName = "" Or PreviousServiceName = ServiceName.Value Then 
            PreviousServiceName = ServiceName.Value 
        Else 
            ServiceName.Value = "" 
        End If 
    End Sub 

But this doesn't do what i would have expected it to do... instead it does the following:

http://s734.photobucket.com/albums/ww342/crazycoders/?action=view&current=teleriklayout2.jpg

And you can see in this picture that the employee name seems to repeat twice then stops but the service name never stops repeating. I don't think my logic is all that bad.. can someone help me try to achieve that layout?

Thanks




1 Answer, 1 is accepted

Sort by
0
Ivan
Telerik team
answered on 06 Apr 2009, 11:43 AM
Hello Groupe CDGI,

Thank you, for your interest in Telerik Reporting.

The reason your code is not working is because you are trying to modify the report definition while the report is being processed. As a general rule of thumb: you should always modify the processing report items when handling processing events (such as the ItemDataBound event), but not the definition report items. You can obtain a reference to the corresponding processing report item by casting the sender parameter of the event to the appropriate processing type, for example:

Dim TextBox As Processing.TextBox = CType(sender, Processing.TextBox)  
'Do something with the processing text box... 

For a better clarification of the report life cycle and the report events, please, visit our online documentation.

Regarding the report layout you are trying to achieve: have you considered to use the Table report item, which is new to the Q1 2009 release? Actually, the Table/Crosstab report items are quite powerful, and you can accomplish such a complex layout, with many nested groups, fairly easy, without any coding at all. You can visit our online examples, and especially the "Product Sales" one, to get a first impression of what you can do with them.

We have also attached a small example project with two reports, that illustrate how you can create a report layout, similar to the one of the screenshot. You will need the Adventure Works database, that comes with our examples, in order to run them. The first report, called "ProductReportWithoutTable" does it the hard way: by handling the NeedDataSource event, and modifying the processing report items on the fly. The second report, named "ProductReportWithTable" simply uses a Table report item with several groups to achieve the same thing automatically, without any coding.

If you have more questions, regarding Telerik Reporting, please, do not hesitate to ask.

All the best,

the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
General Discussions
Asked by
Groupe CDGI
Top achievements
Rank 1
Answers by
Ivan
Telerik team
Share this question
or