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

Need help using Telerik Reporting in Silverlight

9 Answers 198 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Pablo
Top achievements
Rank 1
Pablo asked on 09 May 2012, 06:36 PM
Hi,

I'm trying to emebbed a report viewer in a Silverlight Web application. I've got a reportviewer object in a window and the empty template of my first report loads normally. The problem started with the data population. I need to change some parameters and retrive the data by a WCF service. My first thought was to change the reportViewer.DataContext to pass an ObservableCollection or a list to the report with the data from my service. But it didn't work.

My second thought is to change dinamically the reportviewer.ReportServiceUri, so I've dessigned a litle REST WFC service (asking for /GiveMeReport/Report1 retreives the Report1, using /GiveMeReport/Report2 the second one,etc. and in the reportviewer change the Uri using Urls like ReportServiceUri=http://localhost/Service.svc/GiveMeReport/Report1). I don't know if this is possible but I just started mounting this WCF service and spent 2hours looking for documentation to do this and I didn't find anything. Do I have to send a Telerik.Reporting.Service.Report or a stream? How to implement IReportService and IResourceService?

Can you please send me a link with documentation or a code sample?

I really appreciate your help. Thank you. 

9 Answers, 1 is accepted

Sort by
0
Pablo
Top achievements
Rank 1
answered on 11 May 2012, 12:45 PM
Hi guys,

Any news about this...?

Thank you.
0
Steve
Telerik team
answered on 11 May 2012, 01:11 PM
Hello Pablo,

As the Silverlight Report Viewer runs on the client and the reports are on the server, you cannot create a report object in your Silverlight application. The remote access to the Telerik Reporting Engine is accomplished via Telerik Reporting Service, which acts as a communication interface between the client programs and the report server. So the only way to pass values to your report parameters is via the RenderBegin eventhandler of the report viewer. For more information refer to: Programmatic Initialization of Report Parameter Values in Telerik Reporting Silverlight Viewer.

You can find documentation about the Telerik Reporting WCF service (which is a standard WCF service) in the following articles:

Also the following blog post should guide you in the correct direction:Using Telerik Reporting with WCF RIA Services.

We don't understand the requirements for changing the ReportServiceUri dynamically. This property of the viewer specifies the location of the report service - absolute or relative Uri. To change reports dynamically you should use the ReportViewer.Report property. The Telerik Reporting WCF service includes default report resolvers that are capable to resolve IReportDocument from relative and physical path that points to trdx file (report definition serialized in XML) or from assembly qualified name. Should you need something custom, you might refer to this blog post: Extending Telerik Reporting Service with Custom IReportResolver.

Kind regards,
Steve
the Telerik team

BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

0
Pablo
Top achievements
Rank 1
answered on 14 May 2012, 02:29 PM
Hi,

we've read all the information you sent and also tested it (by the way,  the extending Telerik Reporting Service with Custom IReportResolver doesn't compile...), but we haven't found yet what we need.  

Summarizing the situation, the architecture of our applicattion is simple: a server and many silverlight clients asking for data through a wcf http or https connection. So the main idea is a WCF service with the reports stored which responds to a report viewer (not a self-hosted wcf server).

At the end we are looking for a wcf service which depending on the received string has to process some stored procedures or anothers in a database, then populate a selected report with the resuls and finally send it to the silverlight client (in my vs project wcf is stored in an IIS and referenced in the silverlight project as an external reference, so there are two different projects).

The question: is it possible to overwrite the method that responds to the reportviewer to make it check some variables in the server, populate a document with data and serve the document to a client? If this scenario is possible, could you provice a little sample? By far, we've been working 2days with Telerik's documentation and trying to execute your CustomReportService without success.

Thank you. 
0
Peter
Telerik team
answered on 17 May 2012, 03:43 PM
Hi Pablo,

Generally custom IReportResolver is recommended when you keep your report definitions in a database or another storage different from the file system and you keep the report definitions serialized in XML. Still if you have more special requirements for customization that are not covered with report parameters you can use the IReportResolver. If this is the case check out the attached sample.

However if you just need to pass some report parameters to the report definition and accordingly to the datasource, you can use the approach elaborated in Programmatic Initialization of Report Parameter Values in Telerik Reporting Silverlight Viewer. 

Regards,
Peter
the Telerik team

BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

0
Mehmet
Top achievements
Rank 1
answered on 15 Jan 2014, 10:37 AM
Hi,
I tried your attached sample but the parameters I assigned were not passed from the viewer to the report.

I'm passing parameters this way:
public MainPage()
{
    InitializeComponent();
     
    this.ReportViewer1.RenderBegin += ReportViewer1_RenderBegin;    
 
}
 
void ReportViewer1_RenderBegin(object sender, RenderBeginEventArgs args)
{
    args.ParameterValues.Clear();
 
    args.ParameterValues.Add("Car1", "Toyota");
    args.ParameterValues.Add("Car2", new object[] { "BMW", "Tata" });
    args.ParameterValues.Add("ModelYear", DateTime.Now.Year);
}


And in the server I'm doing this:

public
partial class Report1 : Telerik.Reporting.Report
{
    public Report1()
    {
        InitializeComponent();
 
        this.NeedDataSource += new EventHandler(Report1_NeedDataSource);
        this.DataSource = null;            
 
    }
     
    void Report1_NeedDataSource(object sender, System.EventArgs e)
    {
        //Take the Telerik.Reporting.Processing.Report instance
        Telerik.Reporting.Processing.Report report = (Telerik.Reporting.Processing.Report)sender;          
         
        if (report.Parameters != null && report.Parameters.Count > 0)
        {
            var param1 = report.Parameters["Car1"].Value;
            var param2 = report.Parameters["Car2"].Value;
            var param3 = report.Parameters["ModelYear"].Value;
        }
    }
}


Note  : I read Programmatic Initialization of Report Parameter Values in Telerik Reporting Silverlight Viewer .

Regards,
Mehmet
0
Stef
Telerik team
answered on 15 Jan 2014, 06:20 PM
Hi Mehmet,

The supported report parameters' types are String, Integer, Float, Boolean and DateTime. Passing arrays of objects and custom types is not supported. Try passing the index of the objects or the serialized into string custom object.

I hope this points you into the right direction.

Regards,
Stef
Telerik

New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.

0
Mehmet
Top achievements
Rank 1
answered on 16 Jan 2014, 08:03 AM
Hi Stef,
First of all ,thanks for replying my question.

I changed parameter passing ,according to your comments, with the following.
    public MainPage()
    {
        InitializeComponent();
 
        this.ReportViewer1.RenderBegin += ReportViewer1_RenderBegin;
 
    }
 
    void ReportViewer1_RenderBegin(object sender, RenderBeginEventArgs args)
    {
        args.ParameterValues.Clear();
        args.ParameterValues["Car1"] = "Toyota";
    }
}


But again I received empty parameters.

/// <summary>
/// Summary description for Report1.
/// </summary>
public partial class Report1 : Telerik.Reporting.Report
{
    public Report1()
    {
        InitializeComponent();
 
        this.NeedDataSource += new EventHandler(Report1_NeedDataSource);
        this.DataSource = null;            
 
    }
     
    void Report1_NeedDataSource(object sender, System.EventArgs e)
    {
        //Take the Telerik.Reporting.Processing.Report instance
        Telerik.Reporting.Processing.Report report = (Telerik.Reporting.Processing.Report)sender;          
         
        if (report.Parameters != null && report.Parameters.Count > 0) /// !!!!! report.Parameters.Count is 0
        {
            var param1 = report.Parameters["Car1"].Value;
        }
    }
}


Would you please run this code from your environment?
Thanks.


0
Stef
Telerik team
answered on 16 Jan 2014, 07:41 PM
Hello Mehmet,

The Car1, Car2, ModelYear report parameters should have been added to the report definition in order the code snippet to work. Then they will be mapped by name to the passed collection of values in the ReportViewer.RenderBegin event, and their running values will be in the processing report Parameters collection.

Regards,
Stef
Telerik

New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.

0
Mehmet
Top achievements
Rank 1
answered on 17 Jan 2014, 11:49 AM
Thanks a lot.Last answer solved my problem.
Tags
General Discussions
Asked by
Pablo
Top achievements
Rank 1
Answers by
Pablo
Top achievements
Rank 1
Steve
Telerik team
Peter
Telerik team
Mehmet
Top achievements
Rank 1
Stef
Telerik team
Share this question
or