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

adjusting Textbox.Visibility cause float left for remaining items

6 Answers 364 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Steven
Top achievements
Rank 1
Steven asked on 07 Feb 2013, 03:42 AM
Within the Report.ItemDataBinding event I'm adjusting the Textbox positions within the PageHeader inorder to collapse the height.

ItemDataBindingEvent
 - Loop Items
   - If (Empty) Visibility = False
   -  Loop each items that crosses vertical plane below this item
        - BelowItem.Top = BelowItem.Top.Subtract(hiddenItemHeightUnit);

lowest = pageSection.Items.OrderByDescending(x => x.Bottom.Value).FirstOrDefault();

if (lowest.Bottom.Value + threashold > pageHeader.Height.Value)
    pageHeader.Height = new Telerik.Reporting.Drawing.Unit.Inch(lowest.Bottom.Value + paddingBottom);


This works great except if I have a textbox that is flush to the right border (textAlign.Right).   Within the ReportHeaderSection ItemDataBound event I can verify that the LEFT position is correctly set within the Processing Textbox and the ItemDefinition Textbox, but when rendered its the same as float left.

If I have a textbox in the center and not even the same horzontal row then this does not happend

This is my page header
-----------------------------------------------
[                       Sup Title                    ]
[                          Title                        ]
[ Value1   ]      [Sub Title]                   ]
[ Value2   ]                                         ]
[ Value3   ]                         [    Value4]
-----------------------------------------------

If I set any of the textbox visiblity to false, then all of the textboxes render as float left (SubTitle and Value4)
If I set their height to Zero then re-positioning is possible.




/// <summary>
/// Can only shrink content within the Report.ItemDataBinding Event
/// </summary>
/// <param name="pageHeader"></param>
/// <param name="debug"></param>
public static void ShrinkToContent(this Telerik.Reporting.PageHeaderSection pageHeader, double paddingBottom=0.02D, bool debug=false)
{
    var items = pageHeader.Items.OfType<Telerik.Reporting.TextBox>().Where(x => x.Visible).OrderBy(x => x.Top.Value).ToList();
    double threashold = 0.02;
 
 
    foreach (Telerik.Reporting.TextBox tx in items)
    {
        tx.CanGrow = false;
 
        if (string.IsNullOrEmpty(tx.Value))
        {
            
            // shuffle items beneth this textbox
            foreach (Telerik.Reporting.TextBox item in items.Where(x => x.Visible && x.Top.Value > tx.Top.Value && tx.Left.Value < x.Right.Value && x.Left.Value < tx.Right.Value))
            {
                // item.Location = new Telerik.Reporting.Drawing.PointU(item.Left, item.Top.Subtract(tx.Height));
                item.Top = item.Top.Subtract(tx.Height);
                if (debug)
                {
                    // blue means shiffted
                    item.Style.BackgroundColor = System.Drawing.Color.Blue;
                }
            }
 
            tx.Height = Telerik.Reporting.Drawing.Unit.Zero;
            tx.CanShrink = true;
            // tx.Style.BackgroundColor = System.Drawing.Color.Black;
        }
    }
 
    var stacked = items.OrderByDescending(x => (x.Height.Value <= threashold) ? 0 : x.Bottom.Value).ToList();
    var lowest = stacked.FirstOrDefault();
 
    // TODO
    // If we have a bottom alignment ensure that its bumped up and still on the bottom
    // Colapse between lowest and next above in vertical stack
             
 
    double oldHeight = pageHeader.Height.Value;
    double newHeight = lowest.Bottom.Value;
    if (newHeight < (oldHeight + threashold))
    {
        if (debug)
        {
            pageHeader.Style.BackgroundColor = System.Drawing.Color.Yellow;
        }
                 
        pageHeader.Height = Telerik.Reporting.Drawing.Unit.Inch(newHeight + paddingBottom);
    }
}

6 Answers, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 11 Feb 2013, 02:11 PM
Hello Steven,

It is not clear where are these textBox items in the page or report header. In addition, if we assume they are in the page header, the provided code does not move textBoxes to the left, nor the page header is re-sized as the code works with the definition textBoxes items, not the processing items. As described by my colleague in this forum thread Height on pageheader section, page header and footer are static and not supposed to reflect growing or shrinking data, so please give a try to the mentioned approach with group headers. You can check the attached sample report to see the difference between using the page header and group section header.

On a side note, we recommend reviewing the Design Considerations for Report Item Layout help article.

I hope this helps.

Regards,
Stef
the Telerik team

HAPPY WITH REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

0
Alessandro Strazzari
Top achievements
Rank 1
answered on 30 May 2018, 04:55 PM

I have the same problem! If I set Visible = false in some TextBox, by default, all the TextBoxes on its right float left.

For example in the report attached (Report.FloatLeft.Issue.trdp) if I set imageInterrupted.Visible = false via design or using a ConditionalFormatting rule the textBox3 and all the textBoxes on its right float left, as you can see in Numero.AnchorNone.Design.01 and Numero.AnchorNone.Result.01.

To fix they in their position I must anchor they right, as you can see in Numero.AnchorRight.Design.01 and Numero.AnchorRight.Result.01.

Why? From my point of view if I don't set any anchor the position of the item should be absolute, so not depending from the visibility of the other items.

Furthermore also if I set pageInfoTextBox.Anchoring = Right when I set textBox_FinalPrint.Visible = False pageInfoTextBox flot left! See pageInfoTextBox.Design.01, pageInfoTextBox.Design.02, pageInfoTextBox.Result.01

 

 

 

0
Alessandro Strazzari
Top achievements
Rank 1
answered on 30 May 2018, 04:57 PM
Attach
0
Alessandro Strazzari
Top achievements
Rank 1
answered on 30 May 2018, 04:59 PM
I tryed to attach Report.FloatLeft.Issue.trdp or Report.FloatLeft.Issue.trdx but your ticketing system stop it!
0
Alessandro Strazzari
Top achievements
Rank 1
answered on 30 May 2018, 04:59 PM
I tryed to attacche the .trdp but your ticketing system stop it.
0
Todor
Telerik team
answered on 04 Jun 2018, 11:21 AM
Hi Alessandro,

We have already answered your questions in the support ticket #1169901.

For the benefit of the other community members I will post the answers also here:

The Report Engine by design will release the space occupied by the hidden report items when some conditions are met - check the Visibility section of the Design Considerations for Report Item Layout article.

You can place the report items that may become invisible but should remain their positions in the report in Panels.
When an item is placed in a Panel, its Visibility will not affect the original layout of the items outside the Panel.
With the suggested approach it will not be necessary to set the Anchoring property of the report items.

In the forum it is allowed to attach only images.

Regards,
Todor
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
Tags
General Discussions
Asked by
Steven
Top achievements
Rank 1
Answers by
Stef
Telerik team
Alessandro Strazzari
Top achievements
Rank 1
Todor
Telerik team
Share this question
or