Telerik Forums
Reporting Forum
2 answers
104 views

Hi,

I'm not reporting an issue here, just making a suggestion about a minor change that I would consider as an improvement.

I'm loading at runtime a report template that was created using the standalone report designer. I'm dynamically replacing all the 'DataSources' of the report, and thus I have to go through all the items of the report to find them all.

The first step is to flatten all the items with a recursive call, starting from the 'Report'. I get a list of ReportItem, and I can cycle through this list and find those that inherits from 'DataItem'. From there, I just have to pick all the distinct DataSources from these DataItems.

And it almost works, except that I'm missing the DataSource from the Report itself, as the Report class does not inherit from DataItem but implements IDataItem.

If IDataItem was public, I could simply use it instead of 'DataItem', but as it is internal I have to handle a special case. And I don't like that.

Maybe I'm missing a good reason to keep this interface internal, but if not my suggestion is to make it public.

Regards,

Olivier

Olivier
Top achievements
Rank 1
 answered on 03 Jul 2020
2 answers
217 views

Sometimes in my system display the error in attached image on all reports until I restart IIS or recycle the App Pool. What is it? And how to solve it completely?

Thanks

Katia
Telerik team
 answered on 02 Jul 2020
4 answers
158 views

Hello

I have an issue with a Telerik Report that I am not able to solve. Can you help me, please?

I want some info in the end of each page of the report, always in the end, in the same location.

This information is different on each page (it is personal information of an invoice)

If I put this TextBox in the page footer it always shows the same info, and out of the page footer I dont know how to put it in the same location because the height of the other things of the report is dynamic. Attached there are two pictures with explanations.

My version is Telerik 2012

Thank you very much

Kind regards,

Gema

Katia
Telerik team
 answered on 02 Jul 2020
8 answers
2.2K+ views
I have 4 textboxes in my report, namely totalPriceTextBox, totalCostTextBox, textBox1 and textBox2.

The value for totalPriceTextBox and totalCostTextBox are from datasource fields.

The value for textBox1 is defined as:
=Fields.TotalPrice - Fields.TotalCost

The value for textBox2 is defined as:
=textBox1.Value / Fields.TotalCost * 100

When I view this report in the Preview tab, totalPriceTextBox, totalCostTextBox are textBox1 are successfully displayed. However I get the error as displayed below for textbox2:
An error has occurred while processing Textbox 'textbox2':
The expression contains object 'textbox1' that is not defined in the current context

Can anyone help me on this? Thank you.
AP
Top achievements
Rank 1
Veteran
 answered on 02 Jul 2020
2 answers
134 views

i have this problem like this video

please watch the video for see problem

link video :

https://streamable.com/b0os30

Todor
Telerik team
 answered on 01 Jul 2020
1 answer
379 views
Hello I have successfully applied the web report designer example on your site but while saving the file with the .trdp extension I created "Could not save report 'example.trdp'." I get an error. What should I do? Can you help me?
Peter
Telerik team
 answered on 01 Jul 2020
2 answers
726 views

I have been reading https://www.telerik.com/support/kb/reporting/details/how-to-edit-connection-strings-saved-by-the-standalone-report-designer- 

to view the connection strings that I have created, but for some reason I do not see a Telerik_EAD. The Telerik_AD is for an older version of Reports and does not have the named connection strings.

 

Where is the shared connection string stored by Report Designer?  I'm at version 14.1.20.513?

 

Thanks.

SL
Top achievements
Rank 1
Veteran
 answered on 30 Jun 2020
1 answer
160 views

    So, I have an app which prints a photo of a map which I keep in a cookie and I have to insert it in a telerik report. I also have a few dozen fields which are not inserted in a database. Do I have to get the values for the fields from a database source or is there any other way I can send the values? 

The data is basically stored in my view, so can I somehow take the data from my fields and sent it to the report? 
Same goes for the map? How do I insert the map in the report? I went through the Map Wizard in the Report Designer, but the data sources are the same. 

Katia
Telerik team
 answered on 30 Jun 2020
10 answers
1.8K+ views

Hello,

It took me a long time to get this figure out so I thought I would share it.  I found a lot of PARTIAL examples in the forums and I had to piece this together from them. So I wanted to post something that shows the entire solution to the problem of changing connections for reports.

GOAL: I needed a simple way to manage database connections for .trdp files in a Reporting Rest Service.

SET UP:
1. I have a local development reporting Rest Service running in my local IIS
2. I have a reporting rest service as its own site in an Azure Virtual Machine IIS
3. I have defined 2 connection strings in my local rest service web.config for my local and remote database
4. This service is used by an Angular (version 7 as of post) App with an HTML 5 report viewer

REQUIREMENTS:
1. have a way to use the local connection string when testing locally
2. have a way to use the remote connection string when I "publish/deploy" my rest service tot he remote VM IIS
3. This project will ONLY use .trdp files so I wanted to keep it as simple as possible
4. I had to enable CORS to get this all to work

HOW IT WORKS:
1. Connections defined in web.config
2. a: use C# preprocessors to change the connection:  see here https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives/
    b: used custom build types (Publish_Release & Publish_Debug in addition to the default Debug and Release) for the logic of what connection string to use.
    c: Note that if you want to use build types like me you will need to add them to the Project Properties => Build => Conditional Symbols
3. build custom report resolver to unpackage and assign the connection
4. Use custom resolver in default ReportsController of rest service
5. Note that I moved the definition for the location of the reports folder to the custom resolver
6. I built in a report parameter ("connection") that you will have to add to your report that displays the database server in the report (with username and password removed).  This is just for debugging and can be removed in your context.

 

NOTE: I will show all code including the using statements to make it easier to understand everything going on

1: the web.config connections:

    <add name="conn_dev" connectionString="YourLocalConnection" providerName="System.Data.SqlClient" />
    <add name="conn_live" connectionString="YourRemoteConnection" providerName="System.Data.SqlClient"  />

2 - 3: Custom Resolver

using System;
using System.Configuration;
using System.IO;
using System.Web;
using Telerik.Reporting;
using Telerik.Reporting.Services.Engine;

namespace Regent.Reporting.Resolvers
{
  public class MyResolver : IReportResolver
  {
    private static string _serverPath;
    private static string _conn;

    public MyResolver()
    {
      /* GET server Path */
      _serverPath = HttpContext.Current.Server.MapPath("~/");

      /* GET CONNECTION STRINGS */
      /* Conditionally set connection string based on build mode */
#if (Publish_Release || Publish_Debug)
      _conn = ConfigurationManager.ConnectionStrings["conn_live"].ConnectionString;
#endif
#if (!Publish_Release && !Publish_Debug)
      _conn = ConfigurationManager.ConnectionStrings["conn_dev"].ConnectionString;
#endif

    }

    public ReportSource Resolve(string reportId)
    {
      try
      {
        /* get path to report */
        var reportsPath = Path.Combine(_serverPath, "Reports"); // path to folder where the .trdp reports are kept
        var sourceReportSource = new UriReportSource { Uri = reportsPath + "\\" + reportId };

        //retrieve an instance of the report     
        var reportPackager = new ReportPackager();
        using (var sourceStream = File.OpenRead(sourceReportSource.Uri))
        {
          var report = (Report)reportPackager.UnpackageDocument(sourceStream);
          /* gets server name of connection string without user/password
           and assigns this value to report parameter for display in report */
          report.ReportParameters["connection"].Value = _conn.Split(new [] {';'},2)[0];
          var reportInstance = new InstanceReportSource
          {
            ReportDocument = report
          };
          // assign the connection
          ((SqlDataSource)report.DataSource).ConnectionString = _conn;
          
          return new InstanceReportSource { ReportDocument = reportInstance.ReportDocument };
        }

      }
      catch (Exception e)
      {
        Console.WriteLine(e);
        return null;
      }

    }
  }
}

 

4. Use the custom resolver in the ReportsController

using Regent.Reporting.Resolvers;
using System.Web.Http.Cors;
using Telerik.Reporting.Cache.File;
using Telerik.Reporting.Services;
using Telerik.Reporting.Services.WebApi;

namespace Regent.Reporting.Controllers
{

  //The class name determines the service URL. 
  //ReportsController class name defines /api/report/ service URL.
  [EnableCors(origins: "*"              , headers: "*"              , methods: "*")]
  public class ReportsController : ReportsControllerBase
  {
    private static readonly ReportServiceConfiguration configurationInstance;

    static ReportsController()
    {
      //Setup the ReportServiceConfiguration
      configurationInstance = new ReportServiceConfiguration
      {
        HostAppId = "Regent.Reporting",
        Storage = new FileStorage(),
        ReportResolver = new MyResolver()
      };
    }

    public ReportsController()
    {
      //Initialize the service
.ReportServiceConfiguration = configurationInstance;
    }
  }
}

 

 

In conclusion, I hope this helps someone else.  This was as simple as I could make it change the connection string based on build types for only .trdp reports.  Unfortunately, this forum does not allow posting formatted code so you will have to pull it into your own editor to see it clearly.

Cheers

Eric R | Senior Technical Support Engineer
Telerik team
 answered on 29 Jun 2020
3 answers
741 views
Hi,

I develop my reports with a standard sql connection.
Contrariwise, when I consume the reports in my application I set datasource programmatically (report.DataSource=<DataTable>).
All work good if the report is a simple report.
If it contains a CrossTab the ReportViewer fails and show a message as "An error has occurred while processing Table 'crosstab1': Unable to establesh a connection to the database..."

Thanks,
marc.
Aseman
Top achievements
Rank 1
Veteran
 answered on 29 Jun 2020
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?