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

Silverlight ReportViewer and ReportBook

14 Answers 310 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
ott
Top achievements
Rank 1
ott asked on 08 Sep 2010, 09:13 PM
 Hello.

I develop the Silverlight application with WCF Service, and use Telerik Reporting version 4.1.10.714.
I created the new class MyReportBook:
public class MyReportBook : Telerik.Reporting.ReportBook

In the Silverlight app I set MyReportViewer.Report = "MyReportBook"; (it's the "string" type for the Silverlight ReportViewer)
I add the Reports to the MyReportBook.Reports collection in the runtime.
Now I need transmit parameter value from the Silverlight application to each report in the collection.
As far as I understand, I can do it only through the MyReportBook.
It is possible?

14 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 09 Sep 2010, 09:01 AM
Hello ott,

The following KB article elaborates on passing values to report parameters from the Silverlight client: Programmatic Initialization of Report Parameter Values in Telerik Reporting Silverlight Viewer.

Sincerely yours,
Steve
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
ott
Top achievements
Rank 1
answered on 10 Sep 2010, 05:42 PM
Hi Steve,

Thank you for your answer.
I try to explain my problem:

I inherited MyReport class ftom the Telerik.Reporting.Report class.
MyReport class contains one parameter.

I add instances of this MyReport class into ReportBook.Reports collection in the runtime.
Then I need to set the parameter value for each report.
For example, the value "1" need to be set for the first MyReport instance, "2" for the second instance, etc.

So, I need receive some parameters values from Silverlight client to my ReportBook object - to determine the count of the MyReports and parameter values for these reports.

Is it possible?
0
Steve
Telerik team
answered on 13 Sep 2010, 03:42 PM
Hello ott,

You would need to download the latest internal build of Telerik Reporting, where adding a single report to a report book several times with different parameters values is possible (see release notes). Then you can refer to the article I've referenced in my previous post which is currently the only way to pass values to Telerik IReportDocument.

Greetings,
Steve
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Tomas
Top achievements
Rank 1
answered on 08 Nov 2010, 08:10 PM

Hi Steve,

Can you please explain to me in more detail how this is done. I'm using Telerik Reporting Q2 2010 SP1 (v4.1.10.921).

If I on the Silverlight client side try to add the same parameter twice like this:

private void ReportViewer1_RenderBegin(object sender, Telerik.ReportViewer.Silverlight.RenderBeginEventArgs args)
{
    args.ParameterValues.Add("Param1", 1);
    args.ParameterValues.Add("Param1", 2);
}

I get an exception telling me "An item with the same key has already been added."

Also how can I based on client side logic decide how many instances of a specific report should be added to a Report Book?
So far I've only seen examples where a ReportBook class is made up with hardcoded reports in the constructor like this

public class ReportBook : Telerik.Reporting.ReportBook
{
    public ReportBook()
    {
        this.Reports.Add(new DashBoard());
        this.Reports.Add(new ProductSales());
        this.Reports.Add(new ProductCatalog());
        this.Reports.Add(new ProductLineSales());
    }
}

Is it impossible to do it in a more dynamic way when using Silverlight?

Tomas

0
Tomas
Top achievements
Rank 1
answered on 11 Nov 2010, 02:06 PM

Hi again,

I was able to figure out my first question today using the debugger and having the parameter comboboxes visible in the viewer I was able to see that the parameter values are set in the following format:

TelerikReportingRepeatingParameter1_MyParam
TelerikReportingRepeatingParameter2_MyParam
...

I suppose you always have to start your parameter name with TelerikReportingRepeatingParameter+index and then underscore and then the name of the actual parameter, is this correct? Why isn't this specified anywhere? At least I'm unable find any info about it.
When or where are theese parameters then split and sent to respective instance of the report in the reportbook?

To my second question, (how to build up a reportbook more dynamically in silverlight), I'm still unable to find a good solution, any help is appreciated.

A new question has also popped up, I upgraded to Telerik Reporting Q3 2010 (v4.2.10.1110) earlier today
and I'm not sure if I've messed something up since yesterday or if it's related to the new release but if I don't specify a value for my parameters either in the rendering event or hardcode a value in the reportdesigner I get an error saying:
"One or more parameters are not set or have invalid values."
The behaviour earlier was that the viewer would tell me to supply a value for all parameters and show me the comboboxes to select from but this aint happening anymore?

Can this have anything todo with the property name change from Mergable to Mergeable,
which btw isn't mentioned as breaking change in the release notes.

Tomas

0
Steve
Telerik team
answered on 11 Nov 2010, 02:43 PM
Hello Tomas,

This information is not specified anywhere as we consider this scenario a bit overwhelming and do not want to confuse the other 99% of clients that would never need to use the Report Book for such purpose.
As for adding reports to the report book from the Silverlight client - this is not possible, as currently there is no Silverlight definition i.e. the reports reside on the server.

Regards,
Steve
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Tomas
Top achievements
Rank 1
answered on 11 Nov 2010, 04:00 PM

Hi Steve,

I was affraid you would tell me that, but I'm aware of that I have to create them on the server side and I'm ok with that but can you tell me where these parameters are separated then or some sort of workaround that would allow me to know how many instances I should create? If I somehow could get the number of parameters send from the client to the server I could store this value and in the constructor of the ReportBook read this value and create as many instances of my report as necessary. Maybe it's possible to somehow modify the WCF Services?

Obviously the parameters and their values are stored somewhere.

The scenario is as follows; the user selects one or many invoices from a list that he/she would like to print and now that I've found out how to send the same parameter with different values my main problem currently is to know how many instances to create on the server, but by counting the number of parameters recieved I would know that.

Tomas

0
Steve
Telerik team
answered on 16 Nov 2010, 06:45 PM
Hello Tomas,

Thank you for the thorough description of your scenario. Unfortunate you're quite correct - there is no out of the box solution for this task. Possible solution involving coding is extending the WCF service, but you would have to use several hacks to achieve the desired result which we do not consider a clean solution. We would log that for investigation and when we have a clear concept on how it should work, we would implement it.

Sorry for the inconvenience.

Sincerely yours,
Steve
the Telerik team
See What's New in Telerik Reporting in Q3 2010 on Wednesday, November 17, 11am Eastern Time: Register here>>
0
Tomas
Top achievements
Rank 1
answered on 18 Nov 2010, 02:24 PM

Hi Steve,

Thank you for your're reply. What I ended up doing as (hopefully) a temporary solution is to on the client side first call a wcf service that sets a Session variable on the server with the number of reportinstances to create. The reportbook constructor then reads this value and creates as many instances of the report as specified in the session variable.
Not the ultimate solution but the best I was able to figure out right now without having to modify the ReportService.
Please let me know if you make any progress in this area.

Can you please elaborate on this question that I asked earlier:

"A new question has also popped up, I upgraded to Telerik Reporting Q3 2010 (v4.2.10.1110) earlier today
and I'm not sure if I've messed something up since yesterday or if it's related to the new release but if I don't specify a value for my parameters either in the rendering event or hardcode a value in the reportdesigner I get an error saying:
"One or more parameters are not set or have invalid values."
The behaviour earlier was that the viewer would tell me to supply a value for all parameters and show me the comboboxes to select from but this aint happening anymore?

Can this have anything todo with the property name change from Mergable to Mergeable,
which btw isn't mentioned as breaking change in the release notes."

Thanks

Tomas

0
Steve
Telerik team
answered on 23 Nov 2010, 06:23 PM
Hi Tomas,

I'm glad you were able to find a working temporary solution.
Sadly, the problem with the report parameter in the Silverlight viewer is a bug that slipped into the Q3 release. However the good news is that we've already fixed the issue and released an internal build with the fix, which you can download from your account. The release notes are here.

Again, sorry for the temporary inconvenience.

Regards,
Steve
the Telerik team
See What's New in Telerik Reporting in Q3 2010 on Wednesday, November 17, 11am Eastern Time: Register here>>
0
Mike
Top achievements
Rank 1
answered on 28 Nov 2010, 06:46 AM

Hi Steve,


I have an almost identical scenario to Tomas with rendering a ReportBook in the WCF Report Service, where the number of reports to be included in the ReportBook is dynamic and only known at runtime. The actual number of reports to be added to the report book is based on the data returned from a database query, using complex selection criteria that need to be specified by the user.  I don't  believe this is an at all unusual scenario.

 

I have a number of reports that are currently working from a WPF client using WCF Report Viewer and  accessing a local database. I'm now trying to provide the same reports to Silverlight clients from a central database through the WCF Report Service.   Some of these reports are individual reports, but I have one that is a ReportBook  consisting of dynamically generated reports.   In my case, I'm dealing with historical data on parts, and the ReportBook consist of a summary report, followed by a report for each individual part qualified by the selection criteria.  There is a single data query and subsequent transformation that results in a collection of objects.  These determine the number of reports and associated data sources that need to be added to the report book.


With the WPF client, I'm able to qualify the data from the database and  then assign the report data sources from the resulting object graph.  Since the WCF service just instantiates the default constructor of the report,  the only way of passing selection criteria is through the report parameters collection.  Given  the criteria are fairly complex, my approach is to serialize a selection criteria object on the client and pass the result as a string parameter.  For the individual reports, I'm using the NeedDataSource event to access the report parameters, deserialize the selection criteria, retrieve and transform the required data, and then assign the report data sources. However, this approach doesn't work with the report book, since there is no equivalent ReportBook event to be able to access the report parameters before rendering starts, and therefore no opportunity to instantiate the required report objects and add them to the report book. 


Again the only available (ugly) workaround seems to be the approach Tomas has adopted: making a separate service call to save selection criteria in the user's session.  However, it seems that the required flexibility could be fairly easily accommodated by providing an event on the ReportBook class that allows access to the report parameters after they have been assigned to the report, but before report rendering has started.


Thanks,


Mike

0
Brian Flaherty
Top achievements
Rank 1
answered on 15 Apr 2011, 02:08 PM
I would like to also suggest that creating a dynamic ReportBook from a Silverlight client is a critical feature. I have a situation where the user is given a list of possible reports to include. They mark check boxes to indicate the desired reports. I want to dynamically create a ReportBook that includes their selected information. It would be really nice if the BeginRender event provided a way to specify a list of reports to include in the report book.

One of the workarounds that I considered is to pass a list of the reports as a parameter and then dynamically create the list in the constructor of the report. I have not tried this yet, but I suspect it will be a problem because the parameter values are not available until the NeedsDataSource event fires.
0
Mike
Top achievements
Rank 1
answered on 15 Apr 2011, 03:00 PM
Hi Brian, I initially tried the workaround you're considering, and you're correct that, by the time you can access report parameters in one of the reports, it's too late to be able to dynamically change the ReportBook content. The only useable (ugly) workaround I found was the one Tomas suggested: sending the report parameters through a separate WCF request and saving them in the user's session. Then making the report request and accessing the report parameters from the user session in the ReportBook constructor. I'd still like to encourage Telerik to just expose an event in ReportBook that provides access to the report parameters that were passed in the report request. Mike
0
Stuart
Top achievements
Rank 1
answered on 26 May 2011, 01:46 AM
Similar to Mike (and others), I have the same situation - where a user effectively selects the reports they want in a report book, and this then needs to be dynamically built when the report book is rendered.

If the ReportBook could contain it's own ReportBookParameters (independent to ReportParameters), then this would enable these to be set from the Silverlight application before the ReportBook is rendered, and would allow the Report Book to then dynamically create the necessary reports.

Stuart
Tags
General Discussions
Asked by
ott
Top achievements
Rank 1
Answers by
Steve
Telerik team
ott
Top achievements
Rank 1
Tomas
Top achievements
Rank 1
Mike
Top achievements
Rank 1
Brian Flaherty
Top achievements
Rank 1
Stuart
Top achievements
Rank 1
Share this question
or