views:

694

answers:

5

Is there a way to change SQL Reporting "chart type" and "sub type" at runtime?

I'm working with a .rdlc report and can't seem to figure out the way to change this at runtime. I don't have the "Expression" ability in either of these fields.

A: 

I am trying to do this exact same thing. I have a set of measures that are shown and then a chart underneath that will show only one measure at a time, depending on user input (which of the measures they wish to see in chart form). However, certain measures are better as columns instead of lines, so I'd like to change the chart type at render-time.

My initial idea is to overlap two charts and set their visibility opposite of each other and according to the user dropdown input. Seems like there could be an easier way (if that idea would even work in the first place?)

Thanks.

Some rendering methods don't support overlapping report objects, so you would have to check this and determine what format the report was going to be rendered in by the users.
Nathan
+1  A: 

Looks like it may not be possible until 2008: Microsoft Link

A: 

I'm using 2008 and it is not solved there as far as I can see. There are so many options for chart type and then even more on subtype, I wouldn't want to have to render them all and then show or hide the right one.

I'm wondering if there is a way to parse the XML of the .rdlc and feed it back to the report viewer without having every user getting there own new modified version of the actual .rdlc file.

On a side note, MS just released a new charting package (from the acquisition of Dundas). Maybe I'll dump the report idea and go with the mschart server control.

JHORN
A: 

One possible solution could be to generate both the charts you wanted and then hide one of them based on your requirement.

Syam
+1  A: 

Your .rdlc file is where everything is defined about your report, including report type. So in cases where I want to change something about the report, I just modify the rdlc file using my favorite xml editing method (XmlDocument, XPath, etc.). You would just modify your RDLC file on the fly to change the report type, then display, or save, whatever.

I did this to allow users to set their own report colors, for example, since those are defined in the rdlc as well.

ChrisW
I assume you mean here that you load the RDLC file as a XML node tree, find the node you want to change (a textbox CanShrink property in my case) and then re-write the entire XML document as an RDLC, then point ReportPath at this modified file? Or something like that...
Rob Nicholson