User Preferences and Styling

Who is online?  0 guests and 0 members
Home  »  Articles  »  User Preferences and Styling

User Preferences and Styling

change text size: A A A
Published: 7/29/2010 by  briankmcdonald  - Views:  [1469]  

Last year, I wrote an article with the same title for another site and as with others, I want to get as many people to see my writings as possible. As such, I am going to post the article here. This was created for SQL Server Reporting Services 2005, but a similar method could be used for SSRS 2008. 

The thought of each of us seeing the same exact thing can sometimes seem daunting and boring to users, which can lead to lack of absorption into the user community. Users often desire to be a little unique (or at least different than those sitting around them). As such, here is a way to allow reporting to pull user color preferences and render them in their desired color scheme.

 

1. Let's begin by setting up our table that will contain our color schemes: 

CREATE TABLE SSRS_Styles
(
 StyleID INT PRIMARY KEY IDENTITY(1,1)
 , StyleName VARCHAR(50)
 , ReportBGColor VARCHAR(100)
 , ReportTitleColor VARCHAR(100)
 , TableHeaderBGColor VARCHAR(100)
 , TableHeaderFontColor VARCHAR(100)
 , TableDetailsBGColor VARCHAR(100)
 , TableDetailsFontColor VARCHAR(100)
)

 

* More values could be stored in this table as I am just using a few of the properties from the body and table objects *

 

2. Now I'm going to add a few standard color schemes into the table: 

--Standard Theme 1
INSERT INTO SSRS_Styles
 (StyleName, ReportBGColor, ReportTitleColor, TableHeaderBGColor
 , TableHeaderFontColor, TableDetailsBGColor, TableDetailsFontColor)
VALUES ('Standard Mono-Chrome','White','Black','#6ca6cd', 'White', 'White','Black')

--Standard Theme 2
INSERT INTO SSRS_Styles
 (StyleName, ReportBGColor, ReportTitleColor, TableHeaderBGColor
 , TableHeaderFontColor, TableDetailsBGColor, TableDetailsFontColor)
VALUES ('Standard Go-Green','White','Green','PaleGreen', 'Black', 'White','Black')

--Standard Theme 3
INSERT INTO SSRS_Styles
 (StyleName, ReportBGColor, ReportTitleColor, TableHeaderBGColor
 , TableHeaderFontColor, TableDetailsBGColor, TableDetailsFontColor)
VALUES ('Standard McPorting','White','Blue','Red', 'White', 'White','Black')

--Standard Theme 4
INSERT INTO SSRS_Styles
 (StyleName, ReportBGColor, ReportTitleColor, TableHeaderBGColor
 , TableHeaderFontColor, TableDetailsBGColor, TableDetailsFontColor)
VALUES ('Standard Star Wars','Black','Silver','Gold', 'Black', 'Black','Silver')

 

The records now in the table should be as follows:

Results

  

3. Now in order to make this work we need to store the preference for a particular user in another table: 

CREATE TABLE SSRS_Style_Preferences
(
 PreferenceID INT PRIMARY KEY IDENTITY(1,1)
 , UserName VARCHAR(50)
 , StyleID INT
 , DateLastModified SMALLDATETIME DEFAULT GETDATE()
)

 

4. Insert some users and their preferences (a web form or report could be used to allow the user to change this setting later, but assigning StyleID = 1 as the default will set the report to the mono-chrome standard). 

INSERT INTO SSRS_Style_Preferences (UserName, StyleID) VALUES ('Default',1)
INSERT INTO SSRS_Style_Preferences (UserName, StyleID) VALUES ('GreenMan',2)
INSERT INTO SSRS_Style_Preferences (UserName, StyleID) VALUES ('BrianMcDonald',3)
INSERT INTO SSRS_Style_Preferences (UserName, StyleID) VALUES ('DarthVader',4)

 

The records now in the SSRS_Style_Preferences table should be as follows:

new results

5. Now it is time to switch over to Business Intelligence Development Studio (BIDS) to edit the report to use the "consumers" preferences.

Note that an assumption is made that the author of the report can create a report and return a resultset into a table control. So from within the report, we need to add two text boxes and a table control. Then we need to set some of the property values of the objects as follows:

Body
BackgroundColor = Fields!ReportBGColor.Value

ReportTitle Textbox (shows the title of the report)
BackgroundColor = Fields!ReportBGColor.Value
Color = Fields!ReportTitleColor.Value


CurrentUserPreference Textbox (shows what user was passed in and their preferred style)
BackgroundColor = Fields!ReportBGColor.Value
Color = Fields!ReportTitleColor.Value

Table
TableRow1 (header) BackgroundColor = Fields!TableHeaderBGColor.Value
TableRow1 (header) Color = Fields!TableHeaderFontColor.Value
TableRow2 (detail) Backgroundcolor = Fields!TableDetailsBGColor.Value
TableRow2 (detail Color = Fields!TableDetailsFontColor.Value

 

6. Preview the results for each user:

Screenshots

For my report, I set the available values of the report parameter to a query and got a listing of the usernames from the SSRS_Style_Preferences table. I have included the database object setup script and the rdl file that I created during this process for your enjoyment. Download them here.

 

Until next time, “keep your ear to the grindstone” – Good Will Hunting

 

 

Brian K. McDonald, MCDBA, MCSD
Business Intelligence Consultant – Pragmatic Works Consulting

Email: bmcdonald@pragmaticworks.com | Blog: BI Developer Network

Convert with DTS xChange  | Develop with BI xPress  | Process with TaskFactory | Document with BI Documenter

 

 
0
/5
Avg: 0/5: (0 votes)

Comments (10)

dustinryan
dustinryan said:

That's awesome! Very cool, Brian!

7/29/2010
 · 
 
by
mattdayton
mattdayton said:

Nice post, fun little way to play with ssrs.

7/29/2010
 · 
 
by
briankmcdonald

Thank you both! It does seem to make reporting a little more fun right? Laughing

7/30/2010
 · 
 
by
suhasakole
suhasakole said:

Very nice........ Smile

8/3/2010
 · 
 
by
cbragdon
cbragdon said:

Excellent write-up... 5 starts

10/15/2010
 · 
 
by
Delucia_chris
Delucia_chris said:

This was a great idea, thanks for sharing!

A perfect way to bring consistency accross reports that are worked on by a team of developers.

3/26/2011
 · 
 
by
meganathank
meganathank said:

Innovative idea, Thanks for sharing :)

4/7/2011
 · 
 
by
briankmcdonald

Thanks for all who enjoyed it and took time to comment. Also, don't forget the rating stars cbragdon. :)

4/13/2011
 · 
 
by
Daniel
Daniel said:

Brian, great blog, thanks. 

My personal preferences for report colors are to use corporate colors and not let users tune the report color scheme to their own preferences.  But, there is talk that we are going to be changing some of our corporate colors.  Which would leave me with the tedious task of going back through all the reports to change colors.  I know that find and replace in the XML code would make this a fairly easy task, I think referring to a database for the color scheme makes the task even easier and more maintainable.

I will definitely set this up, and change all my report templates so that changing colors is as easy as a simple update statement.

Thanks again.

4/13/2011
 · 
 
by
briankmcdonald

You're welcome! I love architecting solutions for organizations and users. This one has been very useful in the past. I can't believe that I wrote it nearly two years ago now! Time flies... :)

4/13/2011
 · 
 
by
  • Name:*
  • Email:*
  • Website:
Type the characters you see in the image: *

Most Recent Articles