Click here to Skip to main content
Click here to Skip to main content

Implementing an Ugly Tab Structure in Reporting Services

By , 24 Jun 2008
 

Introduction

In this article, I will show a way to implement a tab structure in a SSRS report; as reporting services doesn't provide a lot of controls to design our reports so we need to use the existing controls to achieve our targets. To create a tab control in a report, I will use simple textbox and table control and visibility property of table control.

Background

I recently came across a post in ASP.NET forums asking about creating a report containing a tab control (How to create Excel like tab layout?). I faced a similar situation a few months back when our client strictly wanted to display only one table at a time in a report. I spent a lot of time to find out a way to achieve this, but had no luck and finally I came up with this approach. I must admit that I was not at all happy implementing such (ugly) tab structure, but the client was ok with this, so I did.

Requirement

So the requirement is that we have three tables which need to be displayed in a report and every table must be associated with a tab and at any given time, only one table will be visible in the report. User can select any of the given tabs and the corresponding table will become visible and the other will be hidden.

Challenges

Following are the problems in implementing a tab structure in reports:

  1. There is no tab control in reports.
  2. We don't have any way to capture events in reports, so we can't show/hide tables based on users' action.
  3. Even if we somehow implement this, we are not sure whether we will have the same output while we export the report in Excel, PDF and other formats.

Solution

Due to the limitations of report designer, we can't fulfill all the requirements so we will implement a tab structure with the following behavior:

We will have three tabs as required, but each tab will have a +/- sign, clicking on which will show/hide the tab data. This +/- sign is due to the use of Visibility can be toggled by another report item property of table control.

At the start, only one table will be visible and the user can click on any other tab (+/- sign). Clicking on tab (+/-) will show/hide the corresponding table. So if all three tabs are in expanded state (i.e. in - state), then all three tables will be visible and if all three tabs are in collapsed state (i.e. in + state), then all three tables will be hidden, tables can be in mixed state too based on tab states.

Implementation

Let's start with the implementation:

  1. Create a new report and add three text boxes and three tables to it, add table headers, create datasets and attach them to tables, etc.
  2. Get three images for the tabs, and set them as BackgoundImage of respective textbox. Also set their InitialToggleState to Expanded.

    TabControl2n.JPG

  3. Select first table, right click -> properties -> Visibility and check the Visibility can be toggled by another report item check box and select the corresponding textbox (tab) name from the Report item dropdown. This will attach the visibility of this table with this text box and a +/- sign will be displayed on that text box for toggling.

    TabControl3n.JPG

  4. Repeat the above step for the other two tables and also set their Initial visibility to Hidden.

That's it, preview the report and the outcome will be something like this:

TabControl4.JPG

A sample report is attached with the article for reference.

Known Issues

Although this tab structure was good enough for display, it has a few issues while exporting.

  1. Exported reports are not the same in PDF and Excel. In PDF, you will see tabs (textboxes) whereas in Excel, you won't.
  2. In PDF, only visible tables will come (The PDF document is rendered to match the current state of any items in the report), whereas in Excel all tables will be displayed irrespective of their visibility state.

History

  • 24th June, 2008: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

akjoshi
Software Developer (Senior)
India India
Member
Dot net developer having expertise in WPF

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionNice jobmemberMember 121682126 Jun '11 - 16:25 
Hi, Akjoshi. Your job is great and very useful to me. But would you please also provide a sample database for your example report? So we can get the example report at first.
AnswerRe: Nice jobmemberakjoshi26 Jun '11 - 18:11 
Thanks buddy; but I won't be able to help you on this, its been a long time back when I was working on this report and at present I don't have any code related to this.
 
You can use any database table having some numeric columns.
GeneralHelpmemberlucacica15 Oct '10 - 0:28 
I think this is brilliant however i am try to implement this concept to a report that have several tables and graphs in one page. I would like to brake the report down in 5 chunks and link them to 5 tabs. Evrytime i use the Ugly Tab Method to expand or collapse the tab i am left with chunk of blank spaces. Can you please help?
GeneralThanks!memberJoshiwashi23 Feb '10 - 15:44 
I really appreciate this article. I've been learning ReportWriter for the last few weeks at work and struggling to get good at it. I couldn't figure out how to toggle visibility of a column till I saw this example with a table. Can't wait to try it at work tomorrow morning. I hope it works in LocalMode, too.
 
Joshi
GeneralI m the one who posted in asp.net forums :)memberShehbazBashir30 Jun '08 - 23:38 
Hey bro..i should really thanks you for the solution. I posted this thing in the asp.net forums.
The funny thing is i wasnt aware that you posted the solution here...in morning my manager called and told me that there is a recent article on codeproject which you should check for your problem... and the link you gave for the asp.net forum showed my post lolxxx
Thanx bro
GeneralCool.memberSyed Mehroz Alam30 Jun '08 - 18:30 
Nice job.
 
Syed Mehroz Alam.
 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130516.1 | Last Updated 24 Jun 2008
Article Copyright 2008 by akjoshi
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid