Telerik Forums
Reporting Forum
4 answers
2.5K+ views
Hello,
I have a report that contains a SubReport. The sub report ReportSource is set to a type name.
What I would like to define in the designer is that the DataSource of the sub report is the same as the DataSource of the main report. How can I do this?
Patrick
Patrick
Top achievements
Rank 2
Iron
Iron
Iron
 answered on 23 Jan 2014
2 answers
210 views
Hi,

I'm trying to layout a cross tab report with 2 sub rows on the Column details.
Take a closer look at my sample.


Thanks,
Ron Jay
Top achievements
Rank 2
 answered on 23 Jan 2014
1 answer
120 views

In other projects I have had no problems using the HTML5 Report viewer extension for MVC but I can not implement it in my current project.


The page containing the report viewer displays "loading.." in the top left corner but the report is never loaded.

I have debugged the application with Fiddler and Firebug but can see no errors.

The report service (Web API) controller is never called which is probably the root cause.



Comparing Fiddler traces between applications where reporting works and the application with the problem shows that the call

http://localhost:34639/ReportViewer/templates/telerikReportViewerTemplate.html is never made



Does anybody have any suggestions on how to debug this problem.

Stef
Telerik team
 answered on 22 Jan 2014
6 answers
502 views
I have been looking for an example of displaying data in objects that have data items in a list. I can display the first level "items" in a table but cannot retrieve the attributeItems data to display.

I want the report to look like this:
Name        Attribute Name     Attribute Value
XXXX        XXXXXXX                XXXXXX
                XXXXXXX                XXXXXX
XXXX        XXXXX                    XXXX
                XXXX                        XXXXXXX
                XXXXX                        XXXXX
I have yet to find any examples using objects or even a decent tutorial on crosstab reports. I have downloaded one project but this is returning a datatable object.

Here is the report code.

namespace

 

 

Reports

 

{

 

 

using System;

 

 

 

using System.Collections.Generic;

 

 

 

using System.ComponentModel;

 

 

 

using System.Drawing;

 

 

 

using System.Windows.Forms;

 

 

 

using Telerik.Reporting;

 

 

 

using Telerik.Reporting.Drawing;

 

 

 

/// <summary>

 

 

 

/// Summary description for CrossTabReport.

 

 

 

/// </summary>

 

 

 

public partial class CrossTabReport : Telerik.Reporting.Report

 

{

 

 

public CrossTabReport()

 

{

 

InitializeComponent();

}

}

[

 

DataObject]

 

 

 

public class CrossTabReportModel {

 

[

 

DataObjectMethod(DataObjectMethodType.Select)]

 

 

 

public CrossTabData getData() {

 

 

 

return new CrossTabData();

 

}

}

 

 

public class CrossTabData {

 

 

 

public CrossTabData() {

 

title =

 

"CROSS TAB DATA";

 

items =

 

new List<CrossTabItem>() {

 

 

 

new CrossTabItem { itemName = "FRED",

 

itemAttributes =

 

new List<ItemAttribute>()

 

{

 

 

new ItemAttribute{ attribName = "HAIR", attribValue= "BROWN"},

 

 

 

new ItemAttribute{ attribName = "EYES", attribValue= "BROWN"},

 

 

 

new ItemAttribute{ attribName = "HEIGHT", attribValue= "5'6"},

 

 

 

new ItemAttribute{ attribName = "WEIGHT", attribValue= "200"}

 

}

},

 

 

new CrossTabItem { itemName = "SAM",

 

itemAttributes =

 

new List<ItemAttribute>()

 

{

 

 

new ItemAttribute{ attribName = "HAIR", attribValue= "BLONDE"},

 

 

 

new ItemAttribute{ attribName = "EYES", attribValue= "BLUE"},

 

 

 

new ItemAttribute{ attribName = "HEIGHT", attribValue= "6'0"},

 

 

 

new ItemAttribute{ attribName = "WEIGHT", attribValue= "210"}

 

}

},

 

 

new CrossTabItem { itemName = "CHILLY",

 

itemAttributes =

 

new List<ItemAttribute>()

 

{

 

 

new ItemAttribute{ attribName = "HAIR", attribValue= "BROWN"},

 

 

 

new ItemAttribute{ attribName = "EYES", attribValue= "GREEN"},

 

 

 

new ItemAttribute{ attribName = "HEIGHT", attribValue= "5'10"},

 

 

 

new ItemAttribute{ attribName = "WEIGHT", attribValue= "150"}

 

}

}

};

}

 

 

public string title { get; set; }

 

 

 

public List<CrossTabItem> items { get; set; }

 

}

 

 

public class CrossTabItem {

 

 

 

public string itemName { get; set; }

 

 

 

public List<ItemAttribute> itemAttributes { get; set; }

 

}

 

 

public class ItemAttribute {

 

 

 

public string attribName { get; set; }

 

 

 

public string attribValue { get; set; }

 

}

}

Thanks for any help.

Stef
Telerik team
 answered on 22 Jan 2014
1 answer
954 views

I have a simple report.

I want this displayed:

--------------------------------------------

Product Name 1

  Product ID 1

     Product 1 Feature 1

     Product 1 Feature 2

     Product 1 Feature 3

Product Name 2

   Product ID 2

      Product 2 Feature 1

      Product 2 Feature 2

-------------------------------------------------------

I have the layout in a table like this (in one column):

--------------------------------------------------------

Fields.ProductName

Fields.ProductID

Fields.ProductFeature

---------------------------------------------------------

The printout is ok but how do you page break for the entire group? In other words, I want a page break after Product 1 Feature 3 and a page break after Product 2 Feature 2.  I have looked everywhere. You don't have a page break for groups.

I am using a Crosstab. How do you set a page break after a Crosstab?

Stef
Telerik team
 answered on 22 Jan 2014
1 answer
168 views

Can someone please tell me what is incorrect with the following code. It only fails when the TIFF is one page.

Public Sub CreateProcessNotesTIFF()
    Dim instanceReportSource As New Telerik.Reporting.InstanceReportSource()
    instanceReportSource.ReportDocument = New ProcessNotes
    instanceReportSource.Parameters.Add(New Telerik.Reporting.Parameter("ProcNo", _procNo))
    instanceReportSource.Parameters.Add(New Telerik.Reporting.Parameter("ApplicantName", _applicantName))
    Dim reportProcessor As New Telerik.Reporting.Processing.ReportProcessor()
    'set any deviceInfo settings if necessary
    Dim deviceInfo As New System.Collections.Hashtable()
    deviceInfo("OutputFormat") = "TIFF"
    deviceInfo("TiffCompression") = "ccitt4"
    deviceInfo("DpiX") = 300
    deviceInfo("DpiY") = 300
    'deviceInfo("DpiX") = 120
    'deviceInfo("DpiY") = 120
    'Dim result As Telerik.Reporting.Processing.RenderingResult = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo)
    Dim result As Telerik.Reporting.Processing.RenderingResult = reportProcessor.RenderReport("IMAGE", instanceReportSource, deviceInfo)
    Dim fileName As String = result.DocumentName + "." + result.Extension
    'Dim path As String = System.IO.Path.GetTempPath()
    Dim path As String = System.IO.Directory.GetCurrentDirectory()
    Dim filePath As String = System.IO.Path.Combine(path, fileName)
    Using fs As New System.IO.FileStream(filePath, System.IO.FileMode.Create)
        fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length)
    End Using
End Sub
The following code has TiffCompression commented and both single and multiple page TIFFs are exported

Public Sub CreateProcessNotesTIFF()
    Dim instanceReportSource As New Telerik.Reporting.InstanceReportSource()
    instanceReportSource.ReportDocument = New ProcessNotes
    instanceReportSource.Parameters.Add(New Telerik.Reporting.Parameter("ProcNo", _procNo))
    instanceReportSource.Parameters.Add(New Telerik.Reporting.Parameter("ApplicantName", _applicantName))
    Dim reportProcessor As New Telerik.Reporting.Processing.ReportProcessor()
    'set any deviceInfo settings if necessary
    Dim deviceInfo As New System.Collections.Hashtable()
    deviceInfo("OutputFormat") = "TIFF"
    'deviceInfo("TiffCompression") = "ccitt4"
    deviceInfo("DpiX") = 300
    deviceInfo("DpiY") = 300
    'deviceInfo("DpiX") = 120
    'deviceInfo("DpiY") = 120
    'Dim result As Telerik.Reporting.Processing.RenderingResult = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo)
    Dim result As Telerik.Reporting.Processing.RenderingResult = reportProcessor.RenderReport("IMAGE", instanceReportSource, deviceInfo)
    Dim fileName As String = result.DocumentName + "." + result.Extension
    'Dim path As String = System.IO.Path.GetTempPath()
    Dim path As String = System.IO.Directory.GetCurrentDirectory()
    Dim filePath As String = System.IO.Path.Combine(path, fileName)
    Using fs As New System.IO.FileStream(filePath, System.IO.FileMode.Create)
        fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length)
    End Using
End Sub




Nasko
Telerik team
 answered on 22 Jan 2014
1 answer
121 views
Hi,


I wanted to computed a defined formula for a cross tab how is it possible to derive my desired result?
See attach image for further detail.
Stef
Telerik team
 answered on 22 Jan 2014
1 answer
232 views

In the sample code below is there a way to tell how many pages exported the pdf has?

Public Sub CreateProcessNotesPDF()
    Dim instanceReportSource As New Telerik.Reporting.InstanceReportSource()
    instanceReportSource.ReportDocument = New ProcessNotes
    instanceReportSource.Parameters.Add(New Telerik.Reporting.Parameter("ProcNo", _procNo))
    instanceReportSource.Parameters.Add(New Telerik.Reporting.Parameter("ApplicantName", _applicantName))
    Dim reportProcessor As New Telerik.Reporting.Processing.ReportProcessor()
    'set any deviceInfo settings if necessary
    Dim deviceInfo As New System.Collections.Hashtable()
    Dim result As Telerik.Reporting.Processing.RenderingResult = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo)
    Dim fileName As String = result.DocumentName + "." + result.Extension
    'Dim path As String = System.IO.Path.GetTempPath()
    Dim path As String = System.IO.Directory.GetCurrentDirectory()
    Dim filePath As String = System.IO.Path.Combine(path, fileName)
    Using fs As New System.IO.FileStream(filePath, System.IO.FileMode.Create)
        fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length)
    End Using
End Sub


Nasko
Telerik team
 answered on 22 Jan 2014
6 answers
1.9K+ views
Hi,

I'm using the ReportProcessor class in order to export reports in an HTML format progmmatically.  I have a couple of questions; I'm about at wit's end, here.

I have a report which contains a sub report.  Each of these reports is encapsulated in a TRDX file.  I create an instance of the main report (let's call it MainReport), which is of type Telerik.Reporting.Report.  I get a reference to MainReport's DataSource property, which is a SqlDataSource, and I set the ConnectionString property to a connection string in my app.config file.  I then instantiate an InstanceReportSource and set the ReportDocument property to my MainReport object.  At this point, I can render the main report via the ReportProcessor.RenderReport method.  All is well and good so far.

My problem is with the sub report.  What do I need to do to include it?  I've looked at the limited amount of documentation over and over but I simply cannot wrap my head around what I need to do.  Here's what almost works:

I create an instance of the sub report the same way I'm instantiating MainReport (we'll call it SubReport).  I then Find() the sub report item within MainReport's Items collection, and after grabbing that reference, I set its ReportSource property to my SubReport instance.

Here's the problem with that:  Apparently this way of doing things is obsolete.  I need to know how to do it correctly.  Also, I need SubReport.DataSource.ConnectionString to be the same as MainReport.DataSource.ConnectionString.  Additionally, there is a Crosstab item within the main report that apparently also needs a ConnectionString, even though the DataSource is the same as MainReport's DataSource.

Here's some code snippets:

//MainReport instantiation  (some code is hidden, but you should get the idea
XmlReaderSettings xmlReaderSettings = new XmlReaderSettings();
xmlReaderSettings.IgnoreWhitespace = true;
ReportXmlSerializer serializer = new ReportXmlSerializer();
XmlReader primaryReportXmlReader = XmlReader.Create(reportDefinition.PrimaryReport.TemplateLocation, xmlReaderSettings);
_primaryReport = (Telerik.Reporting.Report)serializer.Deserialize(primaryReportXmlReader);
primaryReportXmlReader.Close();
             
SqlDataSource reportDataSource = (SqlDataSource)_primaryReport.DataSource;
reportDataSource.ConnectionString = reportDefinition.ConnectionString;
this._instanceReportSource.ReportDocument = _primaryReport;

//We're using a custom class to define a "report definition", which contains data about sub reports,
//so I'm looping through each sub report definition and instantiating it.
foreach (CPSReport cpsSubReport in reportDefinition.SubReports)
{
    XmlReader xmlReader = XmlReader.Create(cpsSubReport.TemplateLocation, xmlReaderSettings);
    Telerik.Reporting.Report subReportInstance = (Telerik.Reporting.Report)serializer.Deserialize(xmlReader);
    xmlReader.Close();
 
    SqlDataSource subReportDataSource = (SqlDataSource)subReportInstance.DataSource;
    subReportDataSource.ConnectionString = reportDefinition.ConnectionString;  //would be handy to automatically get from the main report
    //The following line is hardcoded for now because i've been experimenting.  The string "subReport1" would actually be defined in our custom report definition class.
    Telerik.Reporting.SubReport subReport = _primaryReport.Items.Find("subReport1", true).FirstOrDefault() as Telerik.Reporting.SubReport;
    subReport.ReportSource = subReportInstance;  //obsolete.  what's the right way to do this?
}

Also, as I mentioned, in the rendered report, I get an error about the Crosstab connection string:

An error has occurred while processing Table 'crosstab2': 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. ------------- InnerException ------------- Format of the initialization string does not conform to specification starting at index 0.

Please help?  :)

Thanks!
Steve
Top achievements
Rank 1
 answered on 22 Jan 2014
1 answer
304 views
I must be dense or something, but for the life of me, can't figure out how to get a report viewer control to display a report.
I need to dynamically set the report location and SQL server connection string in the code behind. The reason for this is,
I want to call the report viewer from multiple areas in my asp.net application and populate it with different reports. Also, the
SQL connection string resides in the web.config and is encrypted. I need to decrypt the string before passing it on to the
report to use. Some reports are single layer and others have sub-reports in them.

So, how do I do this in the code behind of a web form? Source code example would greatly be appreciated.

Thanks!
Stef
Telerik team
 answered on 21 Jan 2014
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?