Set Parameters Using Report Viwer But those are not accessible on server side report page

6 posts, 0 answers
  1. Adit
    Adit avatar
    14 posts
    Member since:
    Mar 2015

    Posted 12 May 2015 Link to this post

    I am using MVC Telerik Reporting. I have added parameter using Report Source, when I see html page it seems parameter are added but when I try to access it on code side in NeedDataSource Event, that time I get Paramter Collection is NULL.

     

    1.) Add this Report Source in Report Viwer

    var reportSource = new TypeReportSource() { TypeName = typeof(MBOProReportBook).AssemblyQualifiedName };
    reportSource.Parameters.Add(new Telerik.Reporting.Parameter("OrganizationID", SessionHelper.LastSelectedOrganization.OrganizationID));
    reportSource.Parameters.Add(new Telerik.Reporting.Parameter("Organization", SessionHelper.LastSelectedOrganization));

     

    2.) Use Following to access parameters but getting NULL in parameter collections

    private void IssueReport_NeedDataSource(object sender, EventArgs e)
    {
    Telerik.Reporting.Processing.Report report = (Telerik.Reporting.Processing.Report)sender;
                Organization organization = (Organization)report.Parameters["Organization"].Value;
               string organizationid = (string)report.Parameters["OrganizationID"].Value;

    }

  2. Adit
    Adit avatar
    14 posts
    Member since:
    Mar 2015

    Posted 13 May 2015 Link to this post

    Please check, here I am attaching my demo solution. I have added parameter from report source and try to get its value on NeedData Source event but getting null. And second, I have added one parameter from Report UI, in that I m getting initial value which I have set from UI but does not get updated value in preview click.

    I am using Q1 2015 reporting. 

     

    Here is solution <Removed by admin: Please do not post download links to projects including DEV assemblies - License Agreement>

     

     

     

  3. Stef
    Admin
    Stef avatar
    3610 posts

    Posted 14 May 2015 Link to this post

    Hello Adit,

    To test the provided project we upgraded it to Telerik Reporting v9.0.15.422 (the latest internal build available for download from your Telerik account - Products & Subscriptions - Latest internal builds - Reporting). The result was successfully running application, where the SessionId report parameter value is updated correctly and can be obtained in the report's NeedDataSource event as illustrated in your code snippet.

    Please test to update Newtosoft.Json.dll to the latest possible via Nuget packages manager in Visual Studio, If the problem still occurs, download and install Fiddler, and check the requests and corresponding responses content in Fiddler - Inspectors - Request/Response - Raw tab. Feel free to send us the log file from Fiddler in order to check it.


    In addition, I have removed the link to your attachment. In future we kindly ask you to use private support tickets if you need to share demo projects. Forums allow only images as attachments.

    Thank you for your understanding.

    Regards,
    Stef
    Telerik
    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
  4. Adit
    Adit avatar
    14 posts
    Member since:
    Mar 2015

    Posted 14 May 2015 in reply to Stef Link to this post

    1.) it works after updating Newtosoft.Json.dll latest version. But question is why it is not working with lower version? Older version which we were using that 4.1+ and updated version is 6+. But why it was not working with older version of DLL?

     

    2.) You have checked provided solution. I am getting ReportParameter in NeedDatasourceEvent. Now my question is that How can I get these Report Parameter in either Report Constructor, or in NeedDataSource event on Preview Button click once updating Parameter from UI. Because I am binding DataSource in NeedDataSource event and using Report Paramter for filtering that source.

     

     

    private void IssueReport_NeedDataSource(object sender, EventArgs e)
            {
                Telerik.Reporting.Processing.Report report = (Telerik.Reporting.Processing.Report)sender;
                Organization organization = JsonConvert.DeserializeObject<Organization>((string)report.Parameters["Organization"].Value);
                //string organizationid = (string)report.Parameters["OrganizationID"].Value;
     
                AdminDataProvider adminDataProvider = new AdminDataProvider();
                ReportSearchModel searchParams = new ReportSearchModel();
                searchParams.ProjectKeys = organization.ObjectiveProjects;
                searchParams.IssueType = organization.ObjectiveIssueType;
                searchParams.OrganizationID = organization.OrganizationID;
                searchParams.GetLinkedIssues = true;
                ServiceResponse response = _adminDataProvider.GetAllIssues(searchParams, 100, 1, "", "");
                if (response.Data != null)
                {
                    List<ReportModel> lstReportModel = ((Page<ReportModel>) response.Data).Items;
                    table.DataSource = lstReportModel;
                }
     
    }

     

    I just want to call the same line of code when user Update Report Parameters and click on Preview button. Is that possible? If yes then how can I do that. In my case when I click on Preview Button Report Constructor is called every time but Need Data source call only at once(very first time).

     

  5. Adit
    Adit avatar
    14 posts
    Member since:
    Mar 2015

    Posted 14 May 2015 in reply to Adit Link to this post

    And in Report Constructor I am getting NULL for Report parameters.
  6. Stef
    Admin
    Stef avatar
    3610 posts

    Posted 19 May 2015 Link to this post

    Hello Adit,

    Newtonsoft.Json.dll is required to properly format the messages sent from the viewer to the service, and the assembly must not be installed on the machine and must be compatible with the rest installed Nuget packages.


    About report parameters, their running values can be obtained only during the report processing. The attached demo illustrates our test to reproduce the problem, but the NeedDataSource is called always. The demo uses Telerik Reporting v9.0.15.422.

    Note that if report's data is updated in the meantime, you will need to refresh the viewer after the successful update of the data by using its refreshReport method. For example:
    //update data and on success refresh he viewer
        $('#test').click(function () {
                $.ajax({
                    url: "http://localhost:54772/api/Values",
                    type: "Post",
                    contentType: 'application/json; charset=utf-8',
                    success: function (data) {
                         var reportViewer = $("#reportViewer1").data("telerik_ReportViewer");
                         reportViewer.refreshReport();
                    },
                    error: function () { alert('error'); }
                });
            });
    The reason is that the viewer will display a cached version of the report if you are calling the same report, with the same set of parameters, as the viewer and the report are not aware of the changes in the underlying data.

    I have posted more suggestions to your post in How to get refresh button to grab new data from database, which will allow you to stop the reports caching (the service's configuration settings included in v9.0.15.4220 or force the reporting engine to reprocess the report each time (the DateTime parameter updated from external UI).


    If you need further help, please open a support ticket and send us a runnable demo project illustrating your settings and the problem. Thus we can gather the related questions into single thread and troubleshoot the issue.

    Regards,
    Stef
    Telerik
    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