Help with hiding and setting the width of table columns

3 posts, 0 answers
  1. David
    David avatar
    15 posts
    Member since:
    Nov 2016

    Posted 17 Jul 2018 Link to this post

    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. David
    David avatar
    15 posts
    Member since:
    Nov 2016

    Posted 18 Jul 2018 Link to this post

    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)

  3. Ivan Hristov
    Ivan Hristov avatar
    236 posts

    Posted 23 Jul 2018 Link to this post

    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

    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
Back to Top