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

Hide Table Columns?

21 Answers 1529 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
John Mathis
Top achievements
Rank 1
John Mathis asked on 26 Aug 2009, 12:24 AM
I need to show/hide certain table columns based on values of other columns, at runtime. Can a table column including header and detail row be hidden entirely? I am able to not display the column, but I need it to collapse as though it were not there at all.

21 Answers, 1 is accepted

Sort by
0
Ivan
Telerik team
answered on 27 Aug 2009, 12:40 PM
Hi John Mathis,

Currently there is no way to hide table columns programmatically out of the box. You can modify the table definition with code, in order to remove the desired column from it, but it is not that simple. You see, 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 removing a column 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.

Sincerely yours,
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
Craig Smith
Top achievements
Rank 1
answered on 08 Feb 2010, 04:29 PM
Hi Ivan,

May be I should start a new thread but I am the same request as John.
Depending of the user, I need the column 2 of my table to be hidden or removed (I don't have any problem with the column being removed.

I tried the following before binding the table but no success. Did you have implement something in the most recent version or may be is there a workoaround to do it.
        public ListSIR(string workOrder, string div)  
        {  
            /// <summary>  
            /// Required for telerik Reporting designer support  
            /// </summary>  
            ///   
 
              
 
            InitializeComponent();  
 
 
            //remove container column if mining  
            if (div == "M")  
            {  
                table1.ColumnGroups.Remove(table1.ColumnGroups[1]);  
                table1.Body.Columns.Remove(table1.Body.Columns[1]);  
 
            }  
              
            OracleDataAdapter da = new OracleDataAdapter(getSQL(), ConfigurationManager.ConnectionStrings["OraCon"].ConnectionString);  
            table1.DataSource = da;  
 
              
 
        } 

thank you

0
Ivan
Telerik team
answered on 11 Feb 2010, 10:56 AM
Hi Craig Smith,

Deleting a table column programmatically is not that simple. You need to remove the underlying report items of that column as well. Your best bet will be to create two versions of the same table in the report designer: one with and one without the column in question and compare the differences between them in the InitializeComponent method.

However there is a much simpler method to prevent a certain table column from appearing. If you apply a filter to a column group which always evaluates to false, that will prevent the corresponding table column from appearing. If the column group is static (i.e. it has no grouping criteria specified) you need to make it dynamic first (e.g. by specifying a grouping criteria which groups by a constant value). To illustrate this approach I have created a small sample report (please see the attached file) which allows you to show or hide table columns according to the values of report parameters. The sample uses only group filters - no additional coding is involved at all. You need the AdventureWorks sample database which comes with every installation of our product in order to run that report.

Best wishes,
Ivan
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Craig Smith
Top achievements
Rank 1
answered on 11 Feb 2010, 03:32 PM
Thank you Ivan for your help
0
Hugues Ferland
Top achievements
Rank 1
answered on 14 Apr 2010, 01:56 PM
Ivan,

I tried using the sample, but when previewing the report I get the following error :

"An error has occured while processing Table 'productCrosstab':
Detail group found!"

What's wrong ?

Thanks !
0
Massimiliano Bassili
Top achievements
Rank 1
answered on 16 Apr 2010, 04:57 PM
Pascal, I downloaded and was able to run the project just fine with the latest Q1 version. There must be something you have changed or you are using some old version that can cause such collisions. Try the latest ..
0
Hugues Ferland
Top achievements
Rank 1
answered on 19 Apr 2010, 02:37 PM
Thanks, that was my problem !
0
Mike Shilkov
Top achievements
Rank 1
answered on 21 May 2010, 09:48 AM
Hi Ivan.
Thanks for the hint on how to make some columns invisible.
I've got another issue - is it possible to reorder the columns in runtime? Depending on user settings, I'd like to swap the column groups, is that doable?
Thanks!
0
Sunil Kaim
Top achievements
Rank 1
answered on 23 Jun 2010, 08:09 AM
Hi
I also wish to reorder columns of Telerik Reporting table based on column-set order stored in a db table.
Please provide a solution for the same 
0
Peter
Telerik team
answered on 23 Jun 2010, 11:50 AM
Hi Sunil Kaim,

To achieve dynamical order of the Table item you have to create it programmatically. Check out the "Dynamic" Table in Telerik Reports forum thread where you can find a sample project that illustrates how to create a dynamic Table item. You will need the AdventureWorks sample database which comes with the installation of the product. Just change the connectionString accordingly and you should be able to run it.

Sincerely yours,
Peter
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
Saravanan
Top achievements
Rank 1
answered on 08 Apr 2011, 10:19 AM
Hello Ivan,
    The post has helped me solve the issue of hiding the column. The problem now i am facing is that the column header does not appear in all the pages (eg not in all 2,3 or 4 pages). It appears only in the first page. I would like it appear in all page header. I had tryied draging tableheader to page header it did not work, I also tryied adding a table to pageHeader that also dint work(not able to add table to page header). Can you help me solving this issue. I am using Q3 2010 version of telerik reporting.

Regards,
Saravanan.R
0
Massimiliano Bassili
Top achievements
Rank 1
answered on 11 Apr 2011, 03:32 PM
Try the ColumnHeadersPrintOnEveryPage Property of the Table.

Cheers!
0
Saravanan
Top achievements
Rank 1
answered on 13 Apr 2011, 06:45 AM
Hello Massimiliano,
    The solution has helped me solve the issue. I have a small query in addition. Generally we have a ReportHeader( appears only on the first page of the report) and PageHeader(appears on all the pages generated). How can i do this? I want the company logo and other common fiels on pageheader and the filter that i have applied to get the required output of the report in the pageheader.
    I had tryied to add an other pageheader in the designer.cs file dint work out. Can you help me out?

Regards,
Saravanan.R
0
Saravanan
Top achievements
Rank 1
answered on 14 Apr 2011, 05:25 AM
Hello,
    To create the Header part(ReportHeader, PageHeader) do click out side the design part of the report. I had been trying to click on the header part and add an other Header part :).

Regards,
Saravanan.R
0
CHRISTIAN
Top achievements
Rank 1
answered on 09 Jan 2012, 02:03 PM
The example solution doesn´t work.

Fehler    17    "Telerik.Reporting.ReportParameter" enthält keine Definition für "UI", und es konnte keine Erweiterungsmethode "UI" gefunden werden, die ein erstes Argument vom Typ "Telerik.Reporting.ReportParameter" akzeptiert. (Fehlt eine Using-Direktive oder ein Assemblyverweis?)    C:\Users\c095e021\Downloads\173754_reportlibrary\ReportLibrary\ReportLibrary\SampleReport.Designer.cs    252    30    ReportLibrary

I need to Hide some Columns in my Table...
0
Steve
Telerik team
answered on 09 Jan 2012, 02:14 PM
Hi CHRISTIAN,

The project provided in this thread is created with a version which is two years old now and the API has changed since. As the error correctly says you should delete the UI part of the code referencing the report parameters as it no longer exists. The change has been introduced in the Q1 2010 release, namely Telerik.Reporting.ReportParameter.UI property is now OBSOLETE. I've updated the project to use the current latest version and it works correctly.

All the best,
Steve
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

0
Julian
Top achievements
Rank 1
answered on 27 Aug 2012, 08:41 AM
Hi

I have a couple of questions regarding the posted sample:

1. Does this technique apply only to a crosstab type report? What about a table or a report that doesn't include a crosstab or table? (For example, the Invoice - SalesOrderDetails.cs report in the telerik samples that come with the demo).

2. When looking at the sample in the designer, I can't find where the group filters are that you have applied. I've attached a screenshot of what it looks like in my designer.

0
Chris Gillies
Top achievements
Rank 1
answered on 27 Aug 2012, 11:06 AM
The three items that can be used for tabular layout: table, crosstab, and list are basically the same item with different initial predefined template, so this should answer #1.

Use the group explorer (http://www.telerik.com/help/reporting/ui-group-explorer.html) in extended mode to view your group settings.

Cheers!
0
Julian
Top achievements
Rank 1
answered on 29 Aug 2012, 06:42 AM
There are no (group explorer) groups defined for the SampleReport.cs download.

What I had to do is:

> Click on a cell
> Right-click to bring up the context menu
> Select Column Group or Row Group
> Select Group Properties

The terminology is a little confusing; I'm completely new to reporting and need to satisfy myself the difference between these groups and the (group explorer) groups.
0
Roland
Top achievements
Rank 1
answered on 20 Sep 2012, 09:23 AM
I am using the solution suggested by Ivan, however, I would like to keep the original width of the table after removing a column, so that its width is added e.g. to the width of first column. I have tried the "CanShrink" and "CanGrow" properties, without luck. 
Is there any way to achieve this? Either programatically or with the designer.

Thanks in advance.
0
Steve
Telerik team
answered on 21 Sep 2012, 02:18 PM
Hello Roland,

Apply Docking (e.g. Fill for Ivan's example) for the Table item, so that it is bound to its container and keeps its size.

Kind regards,
Steve
the Telerik team

BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

Tags
General Discussions
Asked by
John Mathis
Top achievements
Rank 1
Answers by
Ivan
Telerik team
Craig Smith
Top achievements
Rank 1
Hugues Ferland
Top achievements
Rank 1
Massimiliano Bassili
Top achievements
Rank 1
Mike Shilkov
Top achievements
Rank 1
Sunil Kaim
Top achievements
Rank 1
Peter
Telerik team
Saravanan
Top achievements
Rank 1
CHRISTIAN
Top achievements
Rank 1
Steve
Telerik team
Julian
Top achievements
Rank 1
Chris Gillies
Top achievements
Rank 1
Roland
Top achievements
Rank 1
Share this question
or