Telerik Forums
Reporting Forum
2 answers
417 views
Hi,

I have encountered a little problem and i would be glad to receive some help.
If I create a stored procedure like this:
CREATE PROCEDURE [dbo].[Telerik] (@ID INT)
AS
BEGIN
 
IF(OBJECT_ID('tempdb..#tmp') IS NOT NULL)
BEGIN
    DROP TABLE #tmp
END
 
CREATE TABLE #tmp
(
ID INT
)
 
INSERT INTO #tmp
    SELECT @ID
     
SELECT * FROM #tmp
 
END
GO
 
EXEC [dbo].[Telerik]  229

result will be quite obvious (it is just a sample to show You my problem).

Now, if I use this stored procedure as a data source command in Telerik Report Designer, it will of course show me the right result in window called "Preview Data Source Results"  but as soon as I click "Finish" button it will not display ANY columns in Data Explorer. Same story happens if I use table variable instead of tmp table. Question is, how can I get columns list in Data Explorer if I'm using tmp table or table variables in stored procedure ? Without it, it is a bit difficult to design anything, as every time I have to create procedure with simple select and proper column names, create data source command based on that procedure, and after that I am changing my procedure to "normal" code (column list in data explorer does not change in this situation). 

How can i avoid this ?

All the best,
Mateusz
Mateusz
Top achievements
Rank 1
 answered on 15 Apr 2013
1 answer
111 views
I read that Telerik Reporting does not support nesting of aggregates and I don't know if there is a way to achieve the following:

* I have a report with a list of amounts and currencies. Some amounts are positive and others are negative.
* I have grouped the amounts by currency.
* In the group footer I put two textboxes:
1) textBox1.Value:  =Sum(IIF(Fields.Amount>=0;Fields.Amount;0))
2) textBox2.Value: =Sum(IIF(Fields.Amount<0;-Fields.Amount;0)) * At the very bottom I need to create a hashcode of respective group footer values. a) textBox3.Value: =Sum(textBox1.Value) b) textBox4.Value: =Sum(textBox2.Value) I can't seem to calculate values based on the group footer results however. Am I missing something really simple?
Yours,

Mattias Åslund


Peter
Telerik team
 answered on 15 Apr 2013
2 answers
112 views
Hi

We use ReportViewer for report visualization, print and export in a silverlight application.  

Sometime after we save exported file(no matter what format) the control show exception of type "IO.IO_SharingViolationFile" please see the screen attached.

We need to hide this message from end user and show him some styled popup message with user friendly text.

We tried to add try{ }catch{ } block but sometime it helps sometime now.

then we looked at control ViewModel code and discovered here the reason why we can't catch this exception 

Below is the code listing:

    private void Save()
    {
        string documentName;
        bool flag;
        RenderingResult viewerModel = base.ViewerModel.exportResult;
        if (viewerModel != null)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.DefaultExt = viewerModel.Extension;
            SaveFileDialog saveFileDialog1 = saveFileDialog;
            if (Application.Current.HasElevatedPermissions)
            {
                documentName = viewerModel.DocumentName;
            }
            else
            {
                documentName = null;
            }
            saveFileDialog1.DefaultFileName = documentName;
            saveFileDialog.Filter = ReportViewerModel.SaveExportCommandImpl.BuildSaveFileDialogFilter(base.ViewerModel.selectedExtensionInfo, viewerModel.Extension, base.ViewerModel.TextResources.AllFiles);
            saveFileDialog.FilterIndex = 1;
            SaveFileDialog saveFileDialog2 = saveFileDialog;
            bool? nullable = saveFileDialog2.ShowDialog();
            flag = (!nullable.GetValueOrDefault() ? false : nullable.HasValue);
            if (flag)
            {
                try
                {
                    Stream stream = saveFileDialog2.OpenFile();
                    using (stream)
                    {
                        byte[] documentBytes = viewerModel.DocumentBytes;
                        stream.Write(documentBytes, 0, (int)documentBytes.Length);
                    }
                }
                catch (Exception exception1)
                {
                    Exception exception = exception1;
                    MessageBox.Show(exception.Message);
                }
            }
            return;
        }
        else
        {
            throw new InvalidOperationException(base.ViewerModel.TextResources.UnableToExportError);
        }
    }

Please pay attention on this block 
  try
                {
                    Stream stream = saveFileDialog2.OpenFile();
                    using (stream)
                    {
                        byte[] documentBytes = viewerModel.DocumentBytes;
                        stream.Write(documentBytes, 0, (int)documentBytes.Length);
                    }
                }
                catch (Exception exception1)
                {
                    Exception exception = exception1;
                    MessageBox.Show(exception.Message);
                }

There is standard MessageBox shown and no exception is throw. It make impossible to work with such type of exeptions please fix it


Alexander
Top achievements
Rank 1
 answered on 13 Apr 2013
5 answers
1.2K+ views
I have a report with a table in it.  The table has four columns I know at design time, but there are a unknown number of dynamic columns that I want to display at run time to the right of the four design time/static columns.  Basically I am trying to replicate a Gantt chart and the first four columns are task names and key dates and the dynamic columns are the days I am going to eventually fill in with a background color if the task lands on the dynamic column representing the day.

I have found a couple samples in the forums for creating dynamic columns, but in all of the examples I get the following exception when I try to apply it to my code.

[NullReferenceException: Object reference not set to an instance of an object.]
   Telerik.Reporting.Processing.Table.CalculateColumns() +328
   Telerik.Reporting.Processing.Table.Measure(MeasureDirection dir, Graphics graphics) +786
   Telerik.Reporting.Processing.ProcessingElement.MeasureElement(MeasureDirection dir, Graphics graphics) +181
   Telerik.Reporting.Processing.ProcessingElement.Measure(MeasureDirection dir, Graphics graphics) +1509
   Telerik.Reporting.Processing.ReportSectionBase.Measure(MeasureDirection dir, Graphics graphics) +48
   Telerik.Reporting.Processing.ProcessingElement.MeasureElement(MeasureDirection dir, Graphics graphics) +181
   Telerik.Reporting.Processing.Group.MeasureElement(MeasureDirection dir, Graphics graphics) +286
   Telerik.Reporting.Processing.Report.MeasureElement(MeasureDirection dir, Graphics graphics) +471
   Telerik.Reporting.Processing.Report.MeasureElement(ProcessingElement elementToMeasure) +220
   Telerik.Reporting.Processing.Report.OnItemProcessed() +79
   Telerik.Reporting.Processing.ReportItemBase.Process(DataMember data) +823
   Telerik.Reporting.Processing.Report.Process(DataMember data, DataItemState state, Boolean interactivityEnabled, Boolean documentMapEnabled) +124
   Telerik.Reporting.Processing.ReportProcessor.ProcessReport(IReportDocument reportDocument, IDictionary processingContext) +1313
   Telerik.Reporting.Processing.ReportProcessor.RenderReport(String format, IReportDocument reportDocument, Hashtable deviceInfo, Hashtable renderingContext, CreateStream createStreamCallback) +579
   Telerik.Reporting.Processing.ReportProcessor.RenderReportStateless(String format, IReportDocument reportDocument, Hashtable deviceInfo, Hashtable renderingContext, CreateStream createStreamCallback) +94
   Telerik.Reporting.Processing.ReportProcessor.RenderReport(String format, IReportDocument reportDocument, Hashtable deviceInfo) +195
   TaskReportPage.ExportToPDF(Report reportToExport) in c:\SourceControl\Phenomblue\Websites\WorkamajigAPI\Website\TaskReportPage.aspx.cs:105
   TaskReportPage.btnGenerateGanttReport_Click(Object sender, EventArgs e) in c:\SourceControl\Phenomblue\Websites\WorkamajigAPI\Website\TaskReportPage.aspx.cs:99
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563


Below is report code that is generating the above error.

namespace SOW.Reports
{
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Linq;
    using System.Windows.Forms;
    using Telerik.Reporting;
    using Telerik.Reporting.Drawing;
    using SOW.DataAccess;
 
    public partial class GanttReport : Telerik.Reporting.Report
    {
        SOWEntities sowContext = null;
 
        public GanttReport(int projectKey)
        {
            InitializeComponent();
 
            sowContext = new SOWEntities();
 
            vListing_Project project = sowContext.vListing_Project.FirstOrDefault(x => x.ProjectKey == projectKey);
 
            /******************** Task Report **********************/
            var tasks = (from task in sowContext.pvTaskReports
                         where task.ProjectKey == projectKey
                         select new
                         {
                             task.Task_Level,
                             task.Task_Name,
                             task.Task_ID,
                             task.Task_Days,
                             task.Plan_Start_Date,
                             task.Plan_Completion_Date,
                             task.Track_Schedules,
                             task.Task_Line_Number,
                             task.Task_Type
                         }).ToList();
 
 
            tblTaskDetails.DataSource = tasks;
        }
 
        private void tblTaskDetails_ItemDataBinding(object sender, EventArgs e)
        {
 
            for (int i = 0; i < 10; i++)
            {
                TableGroup tableGroupColumn = new TableGroup();
                tblTaskDetails.ColumnGroups.Add(tableGroupColumn);
                tblTaskDetails.Body.Columns.Add(new TableBodyColumn(Unit.Inch(.2)));
 
                Telerik.Reporting.TextBox textBoxGroup = new Telerik.Reporting.TextBox();
                textBoxGroup.Value = "x" + i.ToString();
                textBoxGroup.Size = new SizeU(Unit.Inch(.2), Unit.Inch(.2));
                tableGroupColumn.ReportItem = textBoxGroup;
                 
 
                Telerik.Reporting.TextBox textBoxTable = new Telerik.Reporting.TextBox();
                textBoxTable.Value = "";
                textBoxTable.Size = new SizeU(Unit.Inch(.2), Unit.Inch(.2));
                tblTaskDetails.Body.SetCellContent(0, i++, textBoxTable);
                tblTaskDetails.Items.AddRange(new ReportItemBase[] { textBoxTable, textBoxGroup });
            }
 
        }
    }
}

If anyone can provide a better example of how to dynamically add columns to a table that already has columns that would be great!
Benin
Top achievements
Rank 1
 answered on 13 Apr 2013
10 answers
1.0K+ views
I am attempting to build a report with the Q2 2011 reporting tools but am running into numerous issues that are really confusing me. The report itself is part of an existing web project (not in a separate library) where an existing web.config has connection strings specified. When I try to create a new SQL data source the connection strings box lists all of my connections that show up in Server Explorer, but it won't list anything in my web.config. When I let the wizard create a new connection entry (which is identical to the existing one) the report generates  until I add a table and link it to the data source (which it created). At that point it tells me it can't connect to the DB because the connection name may be incorrect. I've confirmed the connection string it created is in the web.config but it still acts like it can't find it. I know the connection strings themselves aren't an issue as I created a new project, copied from the "old" web.config to the new one and they show up in the wizard and everything functions great. The database definitely isn't going down either as it is running on my local box.

Any ideas on what might cause this? I also tried an ObjectDataSource (using my LinqToSql objects) and in the code-behind of the report set the data source of that to a linq query but it won't run it (it was setup in the constructor).
Peter
Telerik team
 answered on 12 Apr 2013
1 answer
122 views
Hello,

I have download and install the actual Telerik Reporting TRIAL. I will try to make a sample but when i drag the ReportViewer-Control to a WPF-View.

It come a error up: "Telerik.Windows.Controls is missing"

What is missing? Which licenses I must buy if I want to use only "Telerik Reporting"?
Stef
Telerik team
 answered on 12 Apr 2013
1 answer
75 views
I've been trying to resolve this issue for over a week now and there's a huge demo of my customer's new site this week and I just cannot solve this issue.  It seems like such a minor thing yet it's causing a huge headache.  I finally tracked down what was causing it but I cannot seem to get around it.

I have a report that has a table inside of it with a 2nd data source.  It displays the data perfectly except for the fact that the text is right up alongside the table cells. If I try to add padding to the table cells it causes some serious display problems.  I've attached two screen shots.  One is the HTML Preview of my report Without padding and one With padding.

This display issue only occurs in HTML not in Print Preview and it exports just fine.  They preview the report through the Telerik WebForm Report Viewer however so I need it to show up appropriately in HTML.

Milen | Product Manager @DX
Telerik team
 answered on 11 Apr 2013
3 answers
135 views
Hello,

I want to generate reports from a Silverlight application. As I saw from the demo, I need to have a ReportViewer in a user control, set the Report Service URI, and set the name of the report. How can I pass the data context of the report from Silverlight to the reporting service?
Peter
Telerik team
 answered on 11 Apr 2013
3 answers
118 views
Hi Telerik Team.
I am new on Telerik reporting and I have looked for any information about what I want to do but any success.
I am trying to do a report which the source is an object I create from my model, which model has a navigation property which is a collection.
For example I create an Object ClassRoom(name, grade, code, amount students, etc) and I have a collection of student belong to that ClassRoom (which is a navigation property in my model), I also have a navigation property in my Entity Studen which is subjtects (Math, English, Spanish, etc), when I create my Object ClassRoom (my datasource) I CANT access to the collections when I am doing my report.
Please if someone can tell me what can I do? I would like to show in my report for example:

ClassRoom 1
Grade First
Code CLAS001
Amount Student 30

Details
Peter   12 years old   Math-9   English-8  Spanish-6
Tom     12 years old   Math-9   English-8  Spanish-6
Pep     12 years old   Math-9   English-8  Spanish-6
Rick     12 years old   Math-9   English-8  Spanish-6

In other things my Object is this was: ClassRoom has Students and Students has Subjects (there are navigation properties collections)
Thanks in advance!
Peter
Telerik team
 answered on 11 Apr 2013
1 answer
274 views
Hi,
       I am am trying to export a report programmatically to then attach to an email. The report runs correctly and is save as expected, I just cannot get the parameter values to pass through to the report, I have followed the advice in the following two articles:

The report being used is used elsewhere in the website in a ReportViewer control wheer it's parameters are set prgramatically and it works correctly.

This is the code I am using is below:
public static string ExportToPdf(string documentName,int periodId, int pupilId)
   {
       ReportProcessor reportProcessor =  new ReportProcessor();
       Hashtable deviceInfo = new Hashtable();
 
       InstanceReportSource instanceReportSource = new InstanceReportSource ();
 
       instanceReportSource.ReportDocument= new ARView2();
       instanceReportSource.ReportDocument.DocumentName = documentName;
 
       instanceReportSource.Parameters.Add(new Telerik.Reporting.Parameter("PeriodID", periodId));
       instanceReportSource.Parameters.Add(new Telerik.Reporting.Parameter("PupilID", pupilId));
 
       RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo);
 
       string fileName = result.DocumentName + "." + result.Extension;
       string filePath = Path.Combine(Path.GetTempPath(), fileName);
 
       using (FileStream fs = new FileStream(filePath, FileMode.Create))
       {
           fs.Write(result.DocumentBytes,0,result.DocumentBytes.Length);
       }
 
       return filePath;
   }

Do you have any ideas as to why my reports is not receiving the parameters as passed to it. This code is setting the parameters via code but using a ReportViewer to see the result, this works as expected.
if (e.Item.Level == 0) return;
 
           string[] parms = e.Item.Value.Split(':');
 
           int periodId = Convert.ToInt32(parms[0]);
           int pupilId = Convert.ToInt32(parms[1]);
 
           var rpt = new ARView2
               {
                   DocumentName = string.Format("{0} {1} {2}",cbPermittedPupils.Text.Trim().Replace(",",""),
                                                       pbARList.SelectedItem.Text.Trim(),
                                                       ((RadPanelItem)pbARList.SelectedItem.Parent).Text)
               };
 
           rvAR.ReportSource = new InstanceReportSource { ReportDocument = rpt };
           rvAR.ReportSource.Parameters.Add(new Parameter("PeriodID", periodId));
           rvAR.ReportSource.Parameters.Add(new Parameter("PupilID", pupilId));
           rvAR.RefreshReport();


 I am using Q3 2012 (6.2.12.1017) in an ASP.NET 4 website.

Thanks

Chris


Chris
Top achievements
Rank 2
 answered on 11 Apr 2013
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?