This is a migrated thread and some comments may be shown as answers.

Telerik.Reporting.Table from code level

18 Answers 936 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Michal
Top achievements
Rank 1
Michal asked on 11 Nov 2009, 02:54 PM
Hello,

I have 2 questions about Telerik.Reporting.Table control.

1. Does anyone know how to create table from code level? I mean row with Headers and rows with values below?
2. How to find proper table cell on existing table?

Regards,
Michal.

18 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 13 Nov 2009, 05:08 PM
Hello Michal,

The Table / Crosstab report item is not a mere grid of cells and has a very complex internal structure. The Report Designer does a great deal of work to simplify common tasks, such as creating the table structure/ adding/removing column/rows, merging cells etc from the table, but the underlying code is far from trivial to post it here. Could you, please, be more specific about what are you trying to accomplish? Perhaps there is a simple solution to your problem, that does not involve a lot of coding.

Best wishes,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Michal
Top achievements
Rank 1
answered on 16 Nov 2009, 09:33 AM
Hi Steve,

Thanks for your reply.

Sure maybe you can help me on the easiest way to resolve my problem.
I have a DataTable like this: DataTable
and I need to show these data like this. table with data
The problem might be with "Alternative columns". I know your table cannot display columns in different colours.

If you can present me any easy way how to do that or show me some tips&tricks I will be grateful.

Regards,
Michal.
0
Ivan
Telerik team
answered on 18 Nov 2009, 01:50 PM
Hello Michal,

Probably the easiest way to create a crosstab with Telerik Reporting is to use the Crosstab Wizard. Simply drag the item called "Crosstab Wizard" from the toolbox to your report and the wizard will start automatically. I am not quite familiar with your specific scenario, but from the provided screenshot it appears you need a very simple crosstab with a single row group and a single column group that aggregates some data. If you still have trouble creating your crosstab with the wizard, could you please elaborate on what are your specific requirements, so we can provide you further assistance?

Regarding the alternating colors of the crosstab columns: this can be accomplished rather easily with conditional formatting without any coding on your side at all. The Crosstab report item supports the ColumnNumber and RowNumber build-in functions which can be used in a formatting expression. The following KB article discusses this technique in-depth. The provided example is about alternating rows of a report, but this works exactly the same way for the crosstab.
 

Best wishes,
Ivan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Michal
Top achievements
Rank 1
answered on 18 Nov 2009, 02:38 PM
Hello Ivan,

Everything sounds perfect and easy, but each time when I try to use wizard I have the error - "Unable to cast object type 'Telerik.Reporting.Crosstab' to type 'Telerik.Reporting.Table'.
See Image.

Because of that I need to do it manually. So, it is why I asked you for help....

Regards,
Michal.
0
Steve
Telerik team
answered on 23 Nov 2009, 01:25 PM
Hello Michal,

The error you receive in the designer looks like something that can happen if you have different assembly versions in your project. Please use the Upgrade Wizard to make sure all assemblies and references are the correct version. Also if you have more than a single version of Telerik Reporting available on your machine, make sure you use the correct toolbox item when dragging items in the designer i.e. it is incorrect to drag & drop an item from Q2 onto Q1 designer and vice versa.
This is the only reason we can think of that could cause such error message which is not even correct as you can cast the CrossTab to Table.
As for doing this with the crosstab item directly, this is not a problem as you have a single row group and  column group aggregating some data. What is your goal/specific requirements that you cannot accomplish with it/need guidance, so we can provide you further assistance?
We would appreciate any additional information you could provide, if still having problems.

Sincerely yours,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Sasan
Top achievements
Rank 1
answered on 26 Oct 2010, 05:55 PM
I am trying to do the same thing, and I am getting an error that says :unable to cast object of type 'Telerik.Reporting.Expressions.AggregateNode' to type 'Telerik.Reporting.Processing.Expressions.FieldsNode'.  Is there any guidance you can provide me for this error?
0
Steve
Telerik team
answered on 27 Oct 2010, 07:33 AM
Hi Sasan,

Judging from the exception, it seems you are trying to cast definition object to its processing counter part which is not possible. Without looking at your code, we can only guess what is the culprit, so our suggestion is to debug your application, this way you would be able to see on which line it throws the error.

Sincerely yours,
Steve
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Sasan
Top achievements
Rank 1
answered on 27 Oct 2010, 03:00 PM
I'm not sure how to debug my conditional formatting property.  I can tell you what I did and maybe that will help.  I have a crosstab in my report.  On the crosstab item, I set conditional formatting to =RowNumber()%2==0 in order to alternate the row color for the crosstab rows.  When I try to view it in the preview panel or run it, I get the error that I described below.

It was stated above that you can use the RowNumber expression on a crosstab item, so I'm not sure what I am doing wrong.  I am using Q2 2010 btw, if that helps anything.  Thanks.
0
Steve
Telerik team
answered on 28 Oct 2010, 02:18 PM
Hello Sasan,

Thank you for the clarification. The problem is coming from the fact you're trying to apply this conditional formatting to the crossTab item itself, when it should be applied to the cells in the body of the crosstab (see attached screenshots).

All the best,
Steve
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Sasan
Top achievements
Rank 1
answered on 28 Oct 2010, 03:46 PM
Thanks for your response.  So I tried putting the conditional formatting rule on the crosstab Cell instead of the whole crosstab.  That makes sense to me.  When I did this, I did not get any errors, but I am not seeing the effect of the rule either.  Is there something overriding the conditional formatting?  I don't have a css style sheet set up for the report, so that can't be affecting it.  I am adding the values to the crosstab in the needdatasource event as follows:
private void crosstab2_NeedDataSource(Object sender, EventArgs e)
{
  Telerik.Reporting.Processing.Table crosstab2 = (Telerik.Reporting.Processing.Table)sender;

  string
sql =@"Here is my query";
  string connectionString = "my connectionstring";
  MySqlDataAdapter adapter =
new MySqlDataAdapter(sql, connectionString);
  DataTable myDataTable =
new DataTable();
  adapter.Fill(myDataTable);
  crosstab2.DataSource = adapter;
}


On the design side I'm not doing anything special.  I added some background colors to cells.  I don't have any background images.  Is there any guidance you can give me?  If you need any additional information please let me know.  Thanks.
0
Steve
Telerik team
answered on 28 Oct 2010, 04:28 PM
Hi Sasan,

I've attached the modified CrossTab demo report I've used to show you how to achieve this functionality. Paste it in the C:\Program Files\Telerik\Reporting Q2 2010\Examples\CSharp\ReportLibrary\Crosstab folder and check its settings.

All the best,
Steve
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Sasan
Top achievements
Rank 1
answered on 28 Oct 2010, 07:38 PM
Hi,
  Thanks for your quick response.  I took a look at the project you attached and it does work when I preview it.  I looked at the settings for 'textboxFact' which has the conditionalFormatting on it to do alternating rows.  I compared every aspect of the properties to my cell, and tried to duplicate it the best I could.  I also looked in the designer.cs file to see what was being generated.  I also made sure those things matched up as well.  I still was not able to get alternating row colors to show though for that cell.
0
Steve
Telerik team
answered on 01 Nov 2010, 05:56 PM
Hi Sasan,

Place the RowNumber() function as Value for the textbox in the CrossTab body and see whether it returns the expected result. I suspect that you have set the conditional formatting to a textbox that is part of a static row group, thus it would be displayed once only. For more information on Table item structure review the following articles:

Greetings,
Steve
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Willy Powell
Top achievements
Rank 1
answered on 18 Nov 2010, 03:07 AM
We just upgraded to the current revision (from 2009 Q3) and now all of our tables are failing with this error:

An error has occurred while processing Table 'tblData2':
Unable to cast object of type 'Telerik.Reporting.Expressions.AggregateNode' to type 'Telerik.Reporting.Processing.Expressions.FieldsNode'.

We are using conditional formatting on the tables (simple alternate row coloring) - not sure if that makes a difference.  The upgrade was performed with the Upgrade Wizard.
0
Steve
Telerik team
answered on 19 Nov 2010, 09:05 AM
Hi Willy,

This is exactly the same error as Sasan reported who use conditional formatting as well. As we advised in previous post, please make sure that you're not applying it to the Table item directly, but to the relevant Crosstab body cell.

Best wishes,
Steve
the Telerik team
See What's New in Telerik Reporting in Q3 2010 on Wednesday, November 17, 11am Eastern Time: Register here>>
0
Win
Top achievements
Rank 1
answered on 02 May 2011, 09:00 AM
Hi,

How to display data in the Telerik reporting table? I have sql datasource and I already assigned it. Is there any AutoGenerateColumns in table's properties??

Thanks you in advance,
Win.
0
Mayur
Top achievements
Rank 1
answered on 19 Feb 2014, 05:30 AM
I am having an issue with Telerik reports. I am using Telerik report in my project. When the reports are loaded in browser; some temporary files are created in Temp folder of Windows. When I am accessing same reports repeatably then there is no issues. But when I am logging off and re-logging in to the website then the old temp files do not get deleted which is causing website running slow needs webserver reset and all.

Can we delete the temporary files through C# code behind.  Please send me code snippet if possible.
0
KS
Top achievements
Rank 1
answered on 21 Feb 2014, 09:31 AM
Tags
General Discussions
Asked by
Michal
Top achievements
Rank 1
Answers by
Steve
Telerik team
Michal
Top achievements
Rank 1
Ivan
Telerik team
Sasan
Top achievements
Rank 1
Willy Powell
Top achievements
Rank 1
Win
Top achievements
Rank 1
Mayur
Top achievements
Rank 1
KS
Top achievements
Rank 1
Share this question
or