TechSpoken
"Any ideas?" is the most frequently-asked question in technical forums. My answer is: yes.

Snips and snails and puppy dog tails: what little polygons are made of

August 10, 2007 18:53 by LSN

When I wrote about the genesis of XMLRSDocs-RDLDocumenter I credited Teo Lachev's MSDN article and its ProgressBarCRI sample as a source of inspiration and code samples for the development of Custom Report Items. 

I neglected to credit Chris Hays, whose PolygonCRI Sample stands behind both Teo's Custom Report Item code and mine. I am happy to say that updates to the SQL Server sample set and the on-line documentation have given Chris' code the pride of place that it deserves.

In my downloaded copy of the samples, PolygonsCustomReportItem shows up in the C:\Program Files\Microsoft SQL Server\90\Samples\Reporting Services\Extension Samples location, although I couldn't tell you exactly what download I picked to get it.  You'll probably find the download instructions buried in the Custom Report Item Sample doc topic, which points to this solution. I'm just skimming this topic now because, frankly, the light gets all bendy-like when I try to read certain portions of the docs, and this is one of them.

In each of the three versions, even though we're each rendering different types of custom content, you're going to find a remarkably similar custom rendering approach:

  • You render to an image, using pretty standard Graphics methods.
  • You create an object of Microsoft.ReportingServices.ReportRendering.Image type and you copy what you rendered to that image.  This operation is done with MemoryStream in all three versions of the code -- I have no idea whether it's required or whether Teo just did it that way because Chris did, so I did it too <g> .
  • You provide this object of Microsoft.ReportingServices.ReportRendering.Image type to the standard rendering process as the item-to-be-rendered, when the engine requests it.
My point, and I do have many of them
(said the little polygon)...

I'm writing about this because in the past week I have answered a question about "rich text formatting" in Reporting Services a bunch of times.  Say you have some content stored in a database with RTF markup or HTML markup.  Right now, if you want to use the out-of-the-box RS output rather than writing something to render the whole report yourself, your best option is to create a Custom Report Item. Your code can reads your markup in the data, along with other attributes of the control (such as size and font) and then render the content to an image, however you think it should appear. 

Not a wonderful option, considering that it won't be searchable text, but do-able. In each answer, for what it's worth, I've also pointed folks to a post on the Katmai RS forum  -- which indicates that happier days may be ahead for those of you in this predicament.  You'll also find that your charting options will improve in Katmai.  Charts have been another big reason to use Custom Report Items in RS.

Still, sometimes nothing beats the low-level approach, and it will be worth your while to understand how to custom-render when the occasion arises, even in Katmai and beyond.

If you're reading this and scratching your head about how these little gimmicky Custom Report Items connect with your data, realize that you've got access to the CustomReportItem's CustomProperties collection at the time you're doing this. (The CustomReportItem's CustomProperties collection is a bit different from the CustomProperties collections of other report elements -- and oh how I wish this were not the case -- but that's another post.) 

Take a look at one of Teo's sample reports.  You will easily see that custom properties can be data bound -- I'll put a truncated version of the XML definition of the ProgressTracker custom item here: 

                    <CustomReportItem Name="progressTracker1">
                     <Type>ProgressTracker</Type>
                    <Style>
                         <!-- style attributes here -->
                     </Style>
                      <CustomProperties>
                       <CustomProperty>
                          <Name>Value</Name>
                          <Value>=Fields!Product_Gross_Profit_Margin_Status_.Value</Value>
                        </CustomProperty>
                       <CustomProperty>
                         <Name>OutlineColor</Name>
                          <Value>Gray</Value>
                        </CustomProperty>
                      <!-- more custom properties here -->
                     </CustomProperties>
                   </CustomReportItem>

How far does this capability go?  As far as you need it to. Looking at Chris's custom report item's attributes, PolygonsCRI has a pretty cozy relationship with a dataset:

<CustomProperties>
<CustomProperty>
   <Name>poly:MaxX</Name>
   <Value>=Max(Fields!X.Value,"DataSet2")+
               iif(Min(Fields!X.Value,"DataSet2")>0, Min(Fields!X.Value,"DataSet2"),0)
 
</Value>
</CustomProperty>
<CustomProperty>
   <Name>poly:MinX</Name>
   <Value>=iif(Min(Fields!X.Value,"DataSet2")>0,0,
               Min(Fields!X.Value,"DataSet2"))
 
</Value>
</CustomProperty>
   <!-- and so on, lots more here -->
</CustomProperties>

If you look at one of RDLDocumenterDesigner's sets of attributes, on the other hand, you will see nothing of the sort. My little custom report item doesn't bind to data at all, because it has a completely different raison d'être. While it knows how to render itself at runtime, it's a design-time utility at heart. Just goes to show what a versatile puppy the Custom Report Item really is.


Comments

June 16. 2008 12:19

AK Sabin

ASP.Net Report Viewer.

=IIf(IsNothing(Fields!Value.Value),"NA",Fields!Value.Value)

This one check if the value is Null or not.
If Value is Null, it displays NA
Else it displays the Value from the Business Entity.

AK Sabin

June 16. 2008 16:48

L

Ok, that's true -- are you making a comment on this article, or just a general contribution to knowledge <g>?

L

May 11. 2009 14:56

IP PBX

that was a hilarious title for this post

IP PBX

May 23. 2009 20:22

Toiletry Kits

After first read I was one of the people scratching my head about how these little gimmicky Custom Report Items connect with my data, but after a few more times I am starting to understand . . .

Toiletry Kits

June 27. 2009 19:24

r4 revolution

Hi,

The topic which you chosen for discussion is really very good....Thanks.

r4 revolution

December 10. 2009 15:01

>L<

Greg,

It's you <g>.

>L<

January 16. 2010 00:16

Lilliam Yamnitz

It's a blessing that I found your article on the net, I'll try it and see how it goes, saved me time and headache trying to figure it out by myself. thanks

Lilliam Yamnitz

January 27. 2010 21:27

repossessed cars for sale

I really enjoyed your post. And your right, that's one fine custom report. :"D

repossessed cars for sale

February 2. 2010 14:48

distributor pulsa murah

Jesus, this code makes me dizzy, but anyway that was a great job

distributor pulsa murah

March 24. 2010 21:59

Pulsa elektrik

thanks a lot for the code, i try it and it works

Pulsa elektrik

May 22. 2010 22:47

rug cleaners service

Carpet Cleaning Services A– We are Professional, Reliable, and Affordable Cleaning Company, offers Commercial Carpet Cleaner, Eco Friendly Carpet Cleaner, Eco Carpet Service, Water Damage Cleaning, Nature Friendly Cleaning.

rug cleaners service

May 22. 2010 22:48

Epm Solution

We are an Oracle Partner focused exclusively on Oracle - Hyperion products.

Epm Solution

July 4. 2010 20:21

pet online

I'm going to subscribe to this blog because it's very interesting

pet online

July 19. 2010 10:45

cheap kindles for sale

My husband and I will be trying the code today. Hope it works. Thanks!

cheap kindles for sale

August 14. 2010 01:05

copy protect

RDLDocumenter which was developed was used to generate the  Custom Report Items with the given data. It is very easy to use this software.

copy protect

August 15. 2010 08:53

Garagentor

Dear my blogger friend, your web page is truly good, but what the aspx at the end of all the pages symbolizes? I only know html. Is aspx unsafe?

Garagentor

August 22. 2010 19:05

new cars

Yeah I like the irony of the blog title.

new cars

August 23. 2010 13:11

Busch gardens coupons

Reporting Convergences Chapter: The several sets of printing instructions>> They are preparing anything well, and they have a good tools in working. They are really a professional in this job.

Busch gardens coupons

Add comment


(Will show your Gravatar icon)

  Country flag

Click to change captcha

biuquote
  • Comment
  • Preview
Loading