How to pass parameters to Telerik reporting service?

8 posts, 1 answers
  1. Sat
    Sat avatar
    7 posts
    Member since:
    Dec 2016

    Posted 29 Dec 2016 Link to this post

    Hi we have a legacy Silverlight application. part of this application saves a DOCX file into database using this code:

    DocxFormatProvider provider = new DocxFormatProvider();
    byte[] mybyte = null;
    mybyte = provider.Export(BodyDoc);
    InvokeOperation<CodeSubCode> iop;
    iop = this.context.InsertBodyToDatabase(mybyte);

     

    As you can see we use DocxFormatProvider to export data from a RadRichText control to a byte array then using InsertBodyToDatabase method it saves the byte into the database.

     

    Now want to read this data (byte array) from database and pass formatted text to a report. for this report we use Telerik Reporting Service as a WCF service based on this tutorial

     

    Now My question is that How can we pass this byte array to this report, in report's toolbox there's a HTMLTextBox But as its name implies it's HTML but our data is array byte (DOCX). 

     

    Could you please shed some light to us and guide us How to do this?

     

    T

  2. Boby
    Admin
    Boby avatar
    605 posts

    Posted 30 Dec 2016 Link to this post

    Hello Sat,

    HTMLTextBox would render HTML, so one option would be to convert the docx documents to HTML. You can first import the data from the database using the DocxFormatProvider, which will give you RadDocument instance. Then you can use HtmlFormatProvider to convert the document to HTML which would be compatible with the HTMLText box. For maximum compatibility of the the exported HTML with Telerik Reporting, you should set some HtmlExportSettings according to the following guidelines (excerpt from the documentation):
    In order to achieve best compatibility of the generated HTML with Telerik Reporting, you should apply the following settings:
    - DocumentExportLevel - Fragment;
    - StylesExportMode - Inline;
    - StyleRepositoryExportMode - DontExportStyles;
    - ExportFontStylesAsTags - true.


    You can read more about the compatibility between the HTML exported by different Telerik controls and Telerik Reporting in the following forum answer: 
    Display the content of rich textbox in Report


    Regards,
    Boby
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Sat
    Sat avatar
    7 posts
    Member since:
    Dec 2016

    Posted 01 Jan in reply to Boby Link to this post

    Thank you so much it works now !

    One more thing: As I mentioned we followed this tutorial for setting up report service in our application, it means that we created a class library and put all of the reports in this projects. In SIlverlight application we could display that report. Now I wonder How we can pass this data to this report, I didn't find some guide on documentation, I thought there should be a something like this But I don't know How to do it?

    ReportViewer1.Report.Parameters["Body"] = html;

     

  4. Nasko
    Admin
    Nasko avatar
    916 posts

    Posted 04 Jan Link to this post

    Hi Sat,

    Detailed information on passing parameter values programmatically when using the Silverlight Report Viewer is present in the ReportViewer.ApplyParameters Event page. Please check this help article for more information and code samples.

    Regards,
    Nasko
    Telerik by Progress
    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 Feedback Portal and vote to affect the priority of the items
  5. Sat
    Sat avatar
    7 posts
    Member since:
    Dec 2016

    Posted 05 Jan in reply to Nasko Link to this post

    Thanks, I followed the link you mentioned. Here's my report:

    <telerik:ReportViewer x:Name="ReportViewer1"
                                ReportServiceUri="../ReportService.svc"
                                ZoomMode="FullPage"
                                Report="BusinessApplication8.Reporting.Letter.Preview, BusinessApplication8.Reporting" ApplyParameters="ReportViewer1_ApplyParameters" Margin="0,55,0,-420" />
            <Button Content="Button" HorizontalAlignment="Left" Margin="130,25,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/>

    Now, when user clicks on Button I want to pass some d

    private void ReportViewer1_ApplyParameters(object sender, Telerik.ReportViewer.Silverlight.ApplyParametersEventArgs args)
    {
        args.ParameterValues["Title"] = "some title";
    }
     
    private void Button_Click(object sender, RoutedEventArgs e)
    {
        ReportViewer1.RefreshReport();
    }

     

    This code just refresh the report, it doesn't pass the "some title" to a field called "Title" in the report.  

    Any idea?

     

    Thanks

  6. Nasko
    Admin
    Nasko avatar
    916 posts

    Posted 05 Jan Link to this post

    Hello Sat,

    The ReportViewer.ApplyParameters Event occurs when the viewer's Report property is changed, a parameter value is changed or refresh/preview is triggered from the viewer UI.

    You can debug your application to check whether your code in the event is being hit.

    Note that the new value will be passed to a report parameter, not to a field in the report.

    Regards,
    Nasko
    Telerik by Progress
    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 Feedback Portal and vote to affect the priority of the items
  7. Sat
    Sat avatar
    7 posts
    Member since:
    Dec 2016

    Posted 05 Jan in reply to Nasko Link to this post

    Thank you so much Nasko for your help. I am a bit confused ! As I mentioned I have defined some properties in the report itself (the report is placed inside another class library project, So the parameters are inside that report). Now I want to pass these parameters from UI (My silverlight project which has a report viewer connected to the report) to the report.

     

    I can't get my head around. :)

     

    Thanks

  8. Answer
    Stef
    Admin
    Stef avatar
    3350 posts

    Posted 09 Jan Link to this post

    Hello Sat,

    Please test the following:
    1. Add a report parameter in the report while designing it and made it visible (Visible=true). Note that report parameters values passed by the viewer are evaluated on processing the report, and thus report parameters are usable in expressions and events;
    2. Use the report's parameters area to update the report parameters' values of the displayed report. Initial values can be sent through the ApplyParameters event handler as well.

    Custom properties of the report class, or parameterized constructors cannot be used for passing data into the report, as reports are called by assembly qualified name (the reporting engine creates an instance of the report using reflection and the default parameterless constructor) or by path to a TRDX|TRDP file (the reporting engine deserializes the content internally).

    Regards,
    Stef
    Telerik by Progress
    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 Feedback Portal and vote to affect the priority of the items
Back to Top