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

Show text box on first record of a subreport

4 Answers 359 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 19 Aug 2011, 08:51 PM
Hello,

I have a subreport that lists "sponsors" of a record in the primary report. I'd like to have the first row in the subreport start with "Sponsors:" and then have the list. I want something like this:

Sponsors:      Bill
                      Joe
                      (Etc.)

I thought I could do this by having a boolean "FirstRow" and set it to true during initialization, then while the text box is binding, do .Visibile = FirstRow, then FirstRow = False. This works, but only for the first instance of the subreport in the main report. Apparently the subreport is not initialized for each primary record or something...

Anyway - does anybody know how I'd go about achieving that kind of behavior?

Thanks,

Mike

4 Answers, 1 is accepted

Sort by
0
Massimiliano Bassili
Top achievements
Rank 1
answered on 22 Aug 2011, 08:44 AM
Your case (at least to me) is a bit of a blur. The subreport item allow you to show another report inside the main report. This report is bound to separate data and you can organize its layout as you wish and I do not get why you need to create a boolean flag in order to render a list of names inside it. Are these names coming from a single field or? The Subreport would be initialized once for each primary record if it is placed in the master report detail section only.
0
Mike
Top achievements
Rank 1
answered on 22 Aug 2011, 04:28 PM
Hello,

Thanks for your reply... Sorry I wasn't clearer...

The subreport has two text boxes - one is static and just says "Sponsors:", next to it is one bound to the sponsor field. To save space, I didn't want to put the sponsors text text in the header. The subreport has no headers/footers... so, it's just a detail section that basically looks like this:

[Box "Sponsors][Box "Fields.Sponsor"]

I want to only show the "Sponsors" box on the first record. 

In the parent report, the subreport is in the detail section, but, it does not seem to get initialized with each record - it's only being initialized once as far as I can tell.

Thanks,

Mike
0
Accepted
Peter
Telerik team
answered on 25 Aug 2011, 03:04 PM
Hi Mike,

You are correct you can alter the Sponsors TextBox.Visible property with binding or Conditional Formatting. Check out the following binding example:
 Property path Expression 
 Visible = RowNumber("SubReport1")=1 

However have in mind that setting the Textbox.Visible to false will leave empty space and all of the items on the right side will move to occupy this empty space. To avoid this behavior you have to add the textboxes on the right side into a Panel item and Dock it to right.

Another approach in order to avoid the layout issues is to use conditional expression for the Value of the TextBox instead of hiding it. For example:

= IIf(RowNumber("SubReport1")=1, "Sponsors", "")

Another and probably the cleanest way to achieve the desired layout is to use a CrossTab instead of Subreports. You can create such CrossTab with the CrossTab Wizard that will guide you through the process of creating a CrossTab for your reports. Their intuitive step by step instructions would get you going in no time as no previous experience is needed when using the wizard. On the Arrange Fields step add the Sponsor field as Row Group. This will add a group by Sponsor. By design the group fields are spanned.

You may find useful Working with Tables Lists and Cross Tabs video.

Kind regards,
Peter
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Mike
Top achievements
Rank 1
answered on 25 Aug 2011, 04:19 PM
Thank you - that nailed it... I didn't realize about the RowNumber function - very helpful.

Mike
Tags
General Discussions
Asked by
Mike
Top achievements
Rank 1
Answers by
Massimiliano Bassili
Top achievements
Rank 1
Mike
Top achievements
Rank 1
Peter
Telerik team
Share this question
or