This is a migrated thread and some comments may be shown as answers.
Help with hiding and setting the width of table columns
2 Answers 66 Views
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 17 Jul 2018, 08:50 PM

Could someone please help with the following.  I have a Telerik Reporting table in the groupHeader  section of an exhibit.  That being said I have a requirement where I need to hide one of the columns (depending on a Boolean test) and then resize the column next to it to the width of both columns to take up the space.  ie:  if Columns 1 & 2 width = .6 and If I hide column 2, increase the size of column 1 to 1.0R.   I have added the following code to the New() method of the report but again I can only hide the column.  For some reason the width (even after my line to resize it) stays at .06. 

tblTest.ColumnGroups(2).Visible = False

tblTest.Body.Columns(1).Width = Telerik.Reporting.Drawing.Unit.Inch(1.0R)

 

If anyone could help with this issue I would be very appreciative.

Thank You in advance.

 

2 Answers, 1 is accepted

Sort by
0
David
Top achievements
Rank 1
answered on 18 Jul 2018, 12:23 PM

Note:  I forgot to mention that the requirement is to hide/resize columns per group in the groupHeader section of the report.  I have made some progress where I was able to resize a column in the GroupHeader section's event, ItemDatabound by increasing the size of one of the textbox's within the column.  See below.

Question:  How do I hide a column in the 'GroupHeader' section of a report?

 

Code to resize a column in GroupHeader Section | ItemDatabound.

Dim grp As Telerik.Reporting.Processing.GroupSection = DirectCast(sender, Telerik.Reporting.Processing.GroupSection)

Dim pnl As Telerik.Reporting.Processing.Panel =  DirectCast(Telerik.Reporting.Processing.ElementTreeHelper.GetChildByName(grp, "pnlMain"), Telerik.Reporting.Processing.Panel)

Dim table As Telerik.Reporting.Processing.Table = DirectCast(Telerik.Reporting.Processing.ElementTreeHelper.GetChildByName(pnl, "tableMain"), Telerik.Reporting.Processing.Table)

DirectCast(Telerik.Reporting.Processing.ElementTreeHelper.GetChildByName(table, "TextBox1"),
Telerik.Reporting.Processing.TextBox).Width = Telerik.Reporting.Drawing.Unit.Inch(1.0R)

0
Ivan Hristov
Telerik team
answered on 23 Jul 2018, 07:11 AM
Hello David,

Modifying the report items should be done before the report processing has begun, because the item properties are not yet captured by the processing engine. The best place to do that is in the report constructor, right after InitializeComponent() method, as explained in Understanding Events article. In ItemDataBound event the report is already in processing stage and the item properties are already read and cached by the engine, so changing them could result in a undesirable behavior.

In this specific scenario it seems that changing the table width is not related to data, so it could be done before the processing stage, as explained above. Additionally you can check the following articles that elaborate on the subject:

Report Life Cycle
Access Report Items Programmatically

Regards,
Ivan Hristov
Progress Telerik
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 Feedback Portal and vote to affect the priority of the items
Asked by
David
Top achievements
Rank 1
Answers by
David
Top achievements
Rank 1
Ivan Hristov
Telerik team
Share this question
or