Telerik Forums
Reporting Forum
1 answer
144 views
Hello,

I am using a formula that should be pretty straightforward in a cross tab field.

= IIf((Exec("rowGroup1", Sum(Fields.Field1)) - RunningValue("rowGroup1", Sum(Fields.Field1))) = 0, 0, (Exec("rowGroup1", Sum(Fields.Field2)) - RunningValue("rowGroup1", Sum(Fields.Field2))) / (Exec("rowGroup1", Sum(Fields.Field1)) - RunningValue("rowGroup1", Sum(Fields.Field1))))

The idea is that we are taking the sum of all values and dividing it but the running total. In most scenarios, this is running correctly and the last value is 0 because the running total is equal to the sum of all values. However, in a couple of instances, a negative number is produced and I can't figure out what's going on. I have checked the values of the sum of all vs the running total and it appears that it should calculate to 0. I'm coming close to a deadline and hoping the community may be able to help.

Thanks
Nasko
Telerik team
 answered on 03 Apr 2015
3 answers
841 views
Dear Telerik Team,

I have a problem.

"An error has occurred while processing Report 'theReport':
Unable to establish a connection to the database. Please, verify that
your connection string is valid. In case you use a named connection
string from the application configuration file, make sure the name is
correct and the connection string settings are present in the
configuration file of your application.
"

I'm
1. Using Telerik Report Q2 2014
2. Designing report using Report Designer (.TRDX)
3. implementing report using ASP.NET v.4 (VB)
4. confuse, it works when i click preview from report designer, but it wont work (saying the above error message) when running it using ASP.NET

the code behind:
Dim uriReportSource As New UriReportSource()
uriReportSource.Uri = Server.MapPath("~/Report/") & "theReport.trdx"
uriReportSource.Parameters.Add(New Telerik.Reporting.Parameter("ID", Request("ID")))
ReportViewer1.ReportSource = uriReportSource


The ConnectionString:
1. in Report Designer/TRDX file, "MyCS"
2. in Web.Config, "MyCS"
3. the same connection string value and the same named connectionString.

Can you help me with this? how can i run my report using asp.net.

Thank you


Nasko
Telerik team
 answered on 03 Apr 2015
2 answers
87 views
How can I display headers in crosstab?
Hoàng
Top achievements
Rank 1
 answered on 03 Apr 2015
1 answer
126 views
Hi,

I have a stacked bar chart and a line chart, both are grouped by a property but i want the grouping label to be displayed lower than the label and also delimiting every group by a line. I have added 2 images which will explain what i want better (the file names are suggestive).
Nasko
Telerik team
 answered on 02 Apr 2015
1 answer
280 views
Hi All

I am using a crosstab for generating a report. Now there is a new requirement, based on the users input there are some columns to be hide. I did follow some approaches and end up with the same problem.

1. Use bindings for the column and set visible false. Resulting column not visible but still white space is still there. (this happens only for grouped columns)
2. Set width to be 0 for the column index. Columns are hidden but space for the header still there and last column header of the grouping is missing

Is there a way to hide any column including header of the crosstab according to the index of the column from left.

following is the code i used for set width of columns

            
int count = 0;
var rowGroups = this.crosstab1.RowGroups;
while (rowGroups != null)
{
    foreach (var group in rowGroups)
    {
        if (hideColumnIndexes.Contains(count))
        {
            group.ReportItem.Width = new Telerik.Reporting.Drawing.Unit(0.000000,
                Telerik.Reporting.Drawing.UnitType.Inch);
        }
    }
    if (rowGroups.Any())
    {
        rowGroups = rowGroups[0].ChildGroups;
    }
    else
    {
        rowGroups = null;
    }
    count++;
}



Nasko
Telerik team
 answered on 02 Apr 2015
1 answer
308 views
I'm using the Standalone report viewer as I'm not a developer, though I can muddle through some stuff. I am writing a report where 95% of the data is in a customer database. 

There is a database that contains the database name of the available customer databases. At run time, the user would select the customer to run the report for, and the report would retrieve the database name from this master database.

I then have two other parameters that the user would need to select based on values in the customer database for the selected customer. I want to generate a list of available values, but to do so, I need to use the first parameter to retrieve the database name, then change the connection string of the second parameter. Once the user selects these values, I can then pass them to the subreports that make up the reports and use them to update the connection strings.

I  have written a custom library using the examples found here so I can change the connection string and it works for the sub reports.

However, I'm trying to figure out a way to do the same for the parameters.  I tried putting my custom function call into the ConnectionString parameter in place of the defined connection that is selected in the Report Viewer but that didnt seem to work, or I didn't do it correctly.

Is there a way to do what I need to here?

Nasko
Telerik team
 answered on 02 Apr 2015
4 answers
645 views
We have some very complex reports that must be fed by a data controller class library.   The Telerik ObjectDataSource the is used to represent controller methods as data sources in the designer assume that the data access methods are static.  Unfortunately, our controllers do not have parameter-less constructors.  It has become more challenging to cope with this limitation ever since the SubReport ReportSource could be something other than a Telerik Report.  I have struggled to find the best way to replace Telerik SubReport ObjectDataSources programmically in your TR Q1 2013 SP1 release.  I am hoping that someone who has a strong opinion will evaluate our approach because Google hasn't revealed a clear answer to us.

Facts and Assumptions About Telerik Reporting

Let's make sure that I have my facts straight:

  1. The recommended way to represent a controller method as a data source in the Telerik Reports designer is the ObjectDataSource. 
  2. The Telerik ObjectDataSource assumes that the controller method it calls is static.  
  3. The recommended way to override a data source programmatically is to bind to the SubReport's NeedDataSource event.
  4. A Report will only fire its NeedDataSource event if the Report's DataSource property is set to null.
  5. A Telerik SubReport acts like a placeholder control.  It could represent a Telerik Report or a blob of text.  This flexibility makes it impossible to directly access the DataSource of a Report that is instantiated by a SubReport at compile time.  Instead, you must programmatically instantiate the Report, change its properties and then replace the SubReport.ReportSource with the new Report instance.

All true?  If not, please explain.

Hypothetical Report

Now suppose we have a nested stack of Telerik Reports where Report1 includes SubReport2 to instantiate Report2 that in turn includes SubReport3 to instantiate Report3.  Report1 is instantiated by an ASP.NET page and bound to the Telerik ReportViewer.  Here's what we would do to replace the ObjectDataSource at run-time:

  1. When we instantiate Report1, we use a custom constructor that receives a LINQ to SQL data context as an argument.  Given a data context, we instantiate our controllers inside Report1.cs.  In the Report1 ItemDataBinding event handler, we replace SubReport2.ReportSource like so:
  2. public Report1(LINQToSQLDataContext dataContext)
    {
        //
        // Required for telerik Reporting designer support
        //
        InitializeComponent();
        // custom constructor actions
        this.DataContext = context;
      
        // for debugging
        detail.ItemDataBound += new EventHandler(detail_ItemDataBound);
        this.detail.ItemDataBinding += new EventHandler(detail_ItemDataBinding);
        // force NeedDataSource to fire
        this.DataSource = null;
        this.NeedDataSource += new EventHandler(Report1_NeedDataSource);
        this.Error += new ErrorEventHandler(Report1_Error);
      
        // replace the subReport in order to pass it the MyContactMethodController to replace its static DataSource
        Report2 emailReport = new Report2SubReport(this.MyContactMethodController);
        this.Report2SubReport.ReportSource = new InstanceReportSource() { ReportDocument = emailReport };
        this.Report2SubReport.ReportSource.Parameters.Add(new Telerik.Reporting.Parameter("parameter1", "=Fields.ID"));
        this.Report2SubReport.ReportSource.Parameters.Add(new Telerik.Reporting.Parameter("effectiveDate", "=Parameters.effectiveDate.Value"));
    }
      
    #region Event Handlers
      
    void Report1_NeedDataSource(object sender, EventArgs e)
    {
        Telerik.Reporting.Processing.Report report = (Telerik.Reporting.Processing.Report)sender;
        var id = report.Parameters["ID"].Value;
        _ID = Convert.ToInt32(ufdID);
        var effectiveDT = report.Parameters["effectiveDate"].Value;
        _effectiveDate = Convert.ToDateTime(effectiveDT);
        this.DataSource = this.MyDataController.GetHighLevelInfo(_ID, _effectiveDate);
    }
      
    // for debugging
    void Report1_ItemDataBinding(object sender, EventArgs e)
    {
        int? id = (((Telerik.Reporting.Processing.ReportItemBase)(sender))).DataObject.RawData as int?;
    }
      
    // for debugging
    void detail_ItemDataBinding(object sender, EventArgs e)
    {
        Telerik.Reporting.Processing.ReportSection reportSection = sender as Telerik.Reporting.Processing.ReportSection;
        HighLevelInfo data = reportSection.DataObject.RawData as HighLevelInfo;
        _ID = data.ID;
    }
      
    // for debugging
    void detail_ItemDataBound(object sender, EventArgs e)
    {
        Telerik.Reporting.Processing.ReportSection reportSection = sender as Telerik.Reporting.Processing.ReportSection;
        var data = reportSection.DataObject.RawData;
    }
      
    void Report1_Error(object sender, ErrorEventArgs eventArgs)
    {
        throw new Exception(string.Format("{0} Telerik Report Exception:  {1}", this.Name, eventArgs.Exception.ToString()), eventArgs.Exception);
    }
    #endregion Event Handlers
2.  In Report2:
public Report2(DataController dc)
{
    //
    // Required for telerik Reporting designer support
    //
    InitializeComponent();
    //
    // TODO: Add any constructor code after InitializeComponent call
    //
    // save controller for the NeedDataSource event handler
    this.MyDataController = dc;
    // force NeedDataSource to fire
    this.DataSource = null;
    this.NeedDataSource += new EventHandler(Report2_NeedDataSource);
    this.Error += new ErrorEventHandler(Report2_Error);
  
    // replace the subReport in order to pass it the MyDataController
    Report3 report3 = new Report3(this.MyDataController);
    // force NeedDataSource to fire
    report3.DataSource = null;
    this.Report3SubReport.ReportSource = new InstanceReportSource() { ReportDocument = report3 };
    this.Report3SubReport.ReportSource.Parameters.Add(new Telerik.Reporting.Parameter("parameter1", "=Parameters.parameter1.Value"));
    this.Report3SubReport.ReportSource.Parameters.Add(new Telerik.Reporting.Parameter("parameter2", "=Parameters.effectiveDate.Value"));
    this.Report3SubReport.ReportSource.Parameters.Add(new Telerik.Reporting.Parameter("parameter3", "=Fields.ID"));
    this.Report3SubReport.ReportSource.Parameters.Add(new Telerik.Reporting.Parameter("parameter4", "=Fields.Name"));
}
  
private DataController MyDataController { get; set; }
  
private void Report2_NeedDataSource(object sender, EventArgs e)
{
    int parameter1 = Convert.ToInt32(this.ReportParameters["parameter1"].Value);
    DateTime effectiveDate = Convert.ToDateTime(this.ReportParameters["effectiveDate"].Value);
    List<DetailInfo> detailList = this.MyDataController.GetDetailInfoList(parameter1, effectiveDate);
    this.DataSource = detailList;
}
  
void Report2_Error(object sender, ErrorEventArgs eventArgs)
{
    throw new Exception(string.Format("{0} Telerik Report Exception:  {1}", this.Name, eventArgs.Exception.ToString()), eventArgs.Exception);
}


3.  In Report3:
public Report3(DataController dc)
{
    //
    // Required for telerik Reporting designer support
    //
    InitializeComponent();
    //
    // TODO: Add any constructor code after InitializeComponent call
    //
    // save controller for the NeedDataSource event handler
    this.MyDataController = dc;
    // force NeedDataSource to fire
    this.DataSource = null;
    this.NeedDataSource += new EventHandler(Report3SubReport_NeedDataSource);
    this.Error += new ErrorEventHandler(Report3SubReport_Error);
}
 
private DataController MyDataController { get; set; }
 
private void Report3SubReport_NeedDataSource(object sender, EventArgs e)
{
    int parameter1 = Convert.ToInt32(this.ReportParameters["applicantUserFormDetailID"].Value);
    DateTime effectiveDate = Convert.ToDateTime(this.ReportParameters["effectiveDate"].Value);
    int parameter3 = Convert.ToInt32(this.ReportParameters["skillCategoryID"].Value);
    List<MoreDetailInfo> moreDetailInfoList = this.MyDataController.GetMoreDetailInfo(parameter1, parameter2, effectiveDate);
    // bind datasource directly to my table.  Binding to this.DataSource leaves the table blank.
    this.MyTable.DataSource = moreDetailInfoList;
}
 
void Report3SubReport_Error(object sender, ErrorEventArgs eventArgs)
{
    throw new Exception(string.Format("{0} Telerik Report Exception:  {1}", this.Name, eventArgs.Exception.ToString()), eventArgs.Exception);
}


Is there a better way to implement this hypothetical report?
 


Jim
Top achievements
Rank 1
 answered on 02 Apr 2015
9 answers
378 views
I just started playing with Telerik Reporting. I'm hoping to migrate a simple single page report I currently do in .net using PDFGenerator.

With PDFGenerator you can embed javascript. In my case I add the following line:
MyDocument.JavaScripts.Add(New DocumentJavaScript("print", "this.print({bUI: false, bSilent: true, bShrinkToFit: true});"))

Which results in the PDF file going straight to the printer.

I created the following code in a new .aspx file using sample code I found in the docs.

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 
        Dim report As New Telerik.Reporting.Report() 
        Dim detail As New Telerik.Reporting.DetailSection() 
        Dim textBox2 As New Telerik.Reporting.TextBox() 
        textBox2.Location = New Telerik.Reporting.Drawing.PointU(New Telerik.Reporting.Drawing.Unit(0, Telerik.Reporting.Drawing.UnitType.Inch), New Telerik.Reporting.Drawing.Unit(0, Telerik.Reporting.Drawing.UnitType.Inch)) 
        textBox2.Value = "Hello World!" 
        textBox2.Location = New Telerik.Reporting.Drawing.PointU(New Telerik.Reporting.Drawing.Unit(1.25, Telerik.Reporting.Drawing.UnitType.Inch), New Telerik.Reporting.Drawing.Unit(0, Telerik.Reporting.Drawing.UnitType.Inch)) 
        textBox2.Size = New Telerik.Reporting.Drawing.SizeU(New Telerik.Reporting.Drawing.Unit(4.75, Telerik.Reporting.Drawing.UnitType.Inch), New Telerik.Reporting.Drawing.Unit(0.25, Telerik.Reporting.Drawing.UnitType.Inch)) 
        detail.Items.AddRange(New Telerik.Reporting.ReportItemBase() {textBox2}) 
        detail.Height = New Telerik.Reporting.Drawing.Unit(0.3, Telerik.Reporting.Drawing.UnitType.Inch) 
        report.Items.Add(DirectCast(detail, Telerik.Reporting.ReportItemBase)) 
        ExportToPDF("Test", report) 
    End Sub 
 
    Sub ExportToPDF(ByVal reportName As String, ByVal reportToExport As Telerik.Reporting.Report) 
        Dim mimeType As StringString = String.Empty 
        Dim ext As StringString = String.Empty 
        Dim encoding As EncodingEncoding = Encoding.[Default] 
        Dim reportBytes As Byte() = ReportProcessor.Render("PDF", reportToExport, Nothing, mimeType, ext, encoding) 
        Dim fileName As String = reportName + ".pdf" 
        Response.Clear() 
        Response.ContentType = mimeType 
        Response.Cache.SetCacheability(HttpCacheability.[Private]) 
        Response.Expires = -1 
        Response.Buffer = False 
        Response.AddHeader("Content-Disposition", String.Format("{0};FileName=""{1}""", "attachment", fileName)) 
        Response.OutputStream.Write(reportBytes, 0, reportBytes.Length) 
        Response.[End]() 
    End Sub 

This code generates a PDF directly just like my PDFGenerator code.

How do I embed javascript directly in the PDF generated by the Telerik Reporting control?



KS
Top achievements
Rank 1
 answered on 02 Apr 2015
3 answers
131 views
Hi,

I'm using the table item to display a simple table with columns A and B:

Column A     Column B
Value_A_1   Value_B_1
Value_A_1   Value_B_2
Value_A_1   Value_B_2
Value_A_2   Value_B_4
Value_A_2   Value_B_5
Value_A_2   Value_B_6

I'd like the report to look like this:
Value_A_1
     Value_B_1
     Value_B_2
     Value_B_3
Value_A_2
     Value_B_4
     Value_B_5
     Value_B_6

If I use a row group grouping by Column A the report looks like this:
Value_A_1  Value_B_1
                   Value_B_2
                   Value_B_3
Value_A_2  Value_B_4
                   Value_B_5
                   Value_B_6

If I use a column group grouping by Column A the report looks like this:
Value_A_1
     Value_B_1
     Value_B_2
     Value_B_3

<Pagebreak>
Value_A_2



     Value_B_4
     Value_B_5
     Value_B_6

Why it does a page break after each group and why it displays the emtpy lines in group Value_A_2?

Best regards,
Gerd
Hinata
Top achievements
Rank 1
 answered on 01 Apr 2015
1 answer
122 views
Hi

Previously I had this (The source of the report definition has not been specified) error when accessing the report on a page however recently I have had it when looking at the report preview.

Creating a blank test project all was OK on a basic report simply showing a barcode.  So I started to match it with my live site and on the second change managed to replicate the issue.  My live site is set to compile for x64.  The test site is set to AnyCpu, switching that to x64 caused the report preview to fail and display the "The source of the report definition has not been specified". Reverting to back AnyCPU and it worked.

I assume that this is a bug...

Regards

Jon
Stef
Telerik team
 answered on 01 Apr 2015
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?