Telerik Forums
Reporting Forum
1 answer
1.4K+ views
My API has a `ReportsController` set up like so:

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

namespace API.Controllers
{
[EnableCors(origins: "*", headers: "*", methods: "*")]
public class ReportsController : ReportsControllerBase
{
static ReportServiceConfiguration configurationInstance;

static ReportsController()
{
configurationInstance = new ReportServiceConfiguration
{
HostAppId = "Html5App",
Storage = new FileStorage(),
ReportResolver = new ReportTypeResolver(),
// ReportSharingTimeout = 0,
// ClientSessionTimeout = 15,
};
}

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

My `App_Start\WebApiConfig.cs`:

    public static class WebApiConfig
    {
        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services

            config.EnableCors();
            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{action}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
        }
    }

My `Global.asax.cs`:

    public class WebApiApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            ReportsControllerConfiguration.RegisterRoutes(GlobalConfiguration.Configuration);
            GlobalConfiguration.Configure(WebApiConfig.Register);
        }
    }

My `web.config` has the recommended binding redirects:

    <dependentAssembly>
        <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.6.0" newVersion="5.2.6.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.6.0" newVersion="5.2.6.0" />
      </dependentAssembly>

As far as I can tell, everything is set up correctly, I can call `api/reports/formats` and see the correct data.  When I try to load this report, I get an error.

$("#reportViewer1").telerik_ReportViewer({
serviceUrl: "http://dev-api/api/reports",
reportSource: {
report: "Logic.Reports.Report1, Logic",
parameters: reportParam
},
});

It displays:
"Error loading the report viewer's templates. (Template = http://dev-api/api/reports/resources/templates/telerikReportViewerTemplate-html)." 

on the page, and displays 

`Failed to load http://dev-api/api/reports/resources/templates/telerikReportViewerTemplate-html: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:64634' is therefore not allowed access.`

in the Chrome console.  I cannot figure out what I am missing.
Silviya
Telerik team
 answered on 08 Jun 2018
3 answers
91 views
I am using the Telerik.Reporting.Map control to build some functionality in the map. What I'd like to achieve is some labels on the left top, left center and left bottom. Whenever I do that, the titles do not sit in 1 line. 

How can I align them so they are on 1 line?
Silviya
Telerik team
 answered on 08 Jun 2018
8 answers
1.9K+ views

Following these guide: 

https://www.telerik.com/blogs/telerik-reporting-and-aspnet-core

https://docs.telerik.com/reporting/html5-report-viewer-asp-net-core-2

to create a REST service for Telerik Report, but whatever I do, I have always get this error:

Am I missing something?

 

 

 

 

 

Todor
Telerik team
 answered on 08 Jun 2018
1 answer
75 views
I have a problem watermarks.
I create my project Telerik Reporting with Winform after build my project by debug or release when i run .exe file in folder bin at my computer i not have watermark but i copy to run other computer is have watermark
T
Top achievements
Rank 1
 answered on 08 Jun 2018
2 answers
119 views

I've followed the instructions in the documentation for setting up a the MVC Report Viewer in my ASP.NET MVC web application. The app path maps to "~/Reports", and in the root of my project I have a folder named 'Reports' which contains the SampleReport.trdp. I believe I have all the other configuration in place (Global.asax, web.config etc.). 

How do I view this sample report? What is the URL for viewing any reports? The documentation is very minimal, are there any tutorials for setting up Telerik reporting in an MVC app?

Ciaran
Top achievements
Rank 1
 answered on 07 Jun 2018
1 answer
305 views

Hi,

I use the asp.net webforms viewer and set the report by setting

    reportViewer1.ReportSource.Identifier = reportFile;

I have a controller which uses a custom resolver

    public class ReportsController : ReportsControllerBase

 

Apparently this page uses the REST service to load the report but how does it know what url to use for the service? I haven't configured this explicitly as far as I can see so it seems to be hardcoded/defaulted?

Rick
Telerik team
 answered on 06 Jun 2018
1 answer
460 views

Hi,

Currently, we have 4 options (Header, Query, Inline, Cookies)  for setting parameters in Http request of web serviced data source. Using these options we are able to set report parameter as the parameters for the Http request of web serviced data source. Instead of that how can we pass parameter inside the body of Http request? Current we are able to send parameter inside the body statically. Is have any other way to bind the value of the parameter inside the body from report parameter.

Peter
Telerik team
 answered on 06 Jun 2018
2 answers
104 views

I'm trying to achieve the result in the attached file.

I have gone through the documentation and I cannot see anything which can help me. The only things I could find were for RadChart.

I'm using Q1 2016 SP1 (with no option to currently update)

Is this possible in the Telerik Reporting framework?

 

 

Todor
Telerik team
 answered on 06 Jun 2018
1 answer
82 views

Hello!

Could i configure the same multiple grouping and blue dash line on Graph? If yes, how i can do this?

Please look at attached image

Thanks!

Rick
Telerik team
 answered on 05 Jun 2018
6 answers
429 views
Within the Report.ItemDataBinding event I'm adjusting the Textbox positions within the PageHeader inorder to collapse the height.

ItemDataBindingEvent
 - Loop Items
   - If (Empty) Visibility = False
   -  Loop each items that crosses vertical plane below this item
        - BelowItem.Top = BelowItem.Top.Subtract(hiddenItemHeightUnit);

lowest = pageSection.Items.OrderByDescending(x => x.Bottom.Value).FirstOrDefault();

if (lowest.Bottom.Value + threashold > pageHeader.Height.Value)
    pageHeader.Height = new Telerik.Reporting.Drawing.Unit.Inch(lowest.Bottom.Value + paddingBottom);


This works great except if I have a textbox that is flush to the right border (textAlign.Right).   Within the ReportHeaderSection ItemDataBound event I can verify that the LEFT position is correctly set within the Processing Textbox and the ItemDefinition Textbox, but when rendered its the same as float left.

If I have a textbox in the center and not even the same horzontal row then this does not happend

This is my page header
-----------------------------------------------
[                       Sup Title                    ]
[                          Title                        ]
[ Value1   ]      [Sub Title]                   ]
[ Value2   ]                                         ]
[ Value3   ]                         [    Value4]
-----------------------------------------------

If I set any of the textbox visiblity to false, then all of the textboxes render as float left (SubTitle and Value4)
If I set their height to Zero then re-positioning is possible.




/// <summary>
/// Can only shrink content within the Report.ItemDataBinding Event
/// </summary>
/// <param name="pageHeader"></param>
/// <param name="debug"></param>
public static void ShrinkToContent(this Telerik.Reporting.PageHeaderSection pageHeader, double paddingBottom=0.02D, bool debug=false)
{
    var items = pageHeader.Items.OfType<Telerik.Reporting.TextBox>().Where(x => x.Visible).OrderBy(x => x.Top.Value).ToList();
    double threashold = 0.02;
 
 
    foreach (Telerik.Reporting.TextBox tx in items)
    {
        tx.CanGrow = false;
 
        if (string.IsNullOrEmpty(tx.Value))
        {
            
            // shuffle items beneth this textbox
            foreach (Telerik.Reporting.TextBox item in items.Where(x => x.Visible && x.Top.Value > tx.Top.Value && tx.Left.Value < x.Right.Value && x.Left.Value < tx.Right.Value))
            {
                // item.Location = new Telerik.Reporting.Drawing.PointU(item.Left, item.Top.Subtract(tx.Height));
                item.Top = item.Top.Subtract(tx.Height);
                if (debug)
                {
                    // blue means shiffted
                    item.Style.BackgroundColor = System.Drawing.Color.Blue;
                }
            }
 
            tx.Height = Telerik.Reporting.Drawing.Unit.Zero;
            tx.CanShrink = true;
            // tx.Style.BackgroundColor = System.Drawing.Color.Black;
        }
    }
 
    var stacked = items.OrderByDescending(x => (x.Height.Value <= threashold) ? 0 : x.Bottom.Value).ToList();
    var lowest = stacked.FirstOrDefault();
 
    // TODO
    // If we have a bottom alignment ensure that its bumped up and still on the bottom
    // Colapse between lowest and next above in vertical stack
             
 
    double oldHeight = pageHeader.Height.Value;
    double newHeight = lowest.Bottom.Value;
    if (newHeight < (oldHeight + threashold))
    {
        if (debug)
        {
            pageHeader.Style.BackgroundColor = System.Drawing.Color.Yellow;
        }
                 
        pageHeader.Height = Telerik.Reporting.Drawing.Unit.Inch(newHeight + paddingBottom);
    }
}
Todor
Telerik team
 answered on 04 Jun 2018
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?