Sections do not shrink if a panel is hidden

10 posts, 0 answers
  1. Philip
    Philip avatar
    17 posts
    Member since:
    Feb 2014

    Posted 03 Aug 2014 Link to this post

    It is true that you can hide panels in a details section, however, the space used in the details section must be as big as everything you have in the section, then if you hide one of the panels, the space already allocated for the panel still shows as white space.

    Is there a way to have the section give up it's allotted space if you are hiding a panel?

    Thanks,

    Philip Carter.

    Attached is a screenshot of the design and result


  2. Stef
    Admin
    Stef avatar
    3036 posts

    Posted 06 Aug 2014 Link to this post

    Hi Philip,

    Please test to use a binding to the Panel.Visible property or a conditional formatting rule to hide it. Then apply the approach described in the Collapse the container when hiding child report items KB article on the section that needs to be collapsed.


    Let us know if you need any further help.

    Regards,
    Stef
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. DevCraft banner
  4. Philip
    Philip avatar
    17 posts
    Member since:
    Feb 2014

    Posted 06 Aug 2014 in reply to Stef Link to this post

    I figured that out already. I have a problem with the Page Header section showing as white space in the Report Header Section even when it is hidden and if I shrink the height down, then when it is visible, it is that small and doesn't show the header (see screenshots attached). This is a problem because I often use the report header to do a couple of introductory pages that have to use up the entire first couple of pages.
  5. Philip
    Philip avatar
    17 posts
    Member since:
    Feb 2014

    Posted 07 Aug 2014 Link to this post

    I figured out what to do and I'm going to post it in simple English because coming from a CrystalReports crappy way of doing things, the way Telerik does reporting is way cooler, but completely foreign to anyone used to Crystal Reports.

    So here's the jist. If you use the Report Header to build pages that you want before your details section, you will add a group with no grouping expression and that will give you your Group Header where you will put what you want to be your page header and then set the PrintOnEverPage Property to True. then hide the Page Header so no space is taken up on the details pages.

    Also, anyone coming from Crystal Reports, should also look at the Bindings property of sections and items. Because there, you can set page breaks and the other things that you are not able to set in the standard conditional formatting. It's a very cool way of doing things.

    Thanks Telerik!!!

    In case anyone is interested, Here's a link to the report and subreport. It may help you figure out what you can do above and beyond what you can do with Crystal. http://marketplacesoftware.biz/LiveUpdate/ForwardTilt-Proposal.zip  
  6. Stef
    Admin
    Stef avatar
    3036 posts

    Posted 11 Aug 2014 Link to this post

    Hi Philip,

    Thank you for your kind words and we are happy to hear you found a solution.

    Just in case later you need to use the global objects available in the page sections, you can try a document layout built by several report definitions, which are gathered in a Reportbook. In a report book, each new report starts on a new page, you can add content with different structure, and the whole book is treated as a single document on processing.


    I hope the above information helps you.

    Regards,
    Stef
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  7. David A.
    David A. avatar
    126 posts
    Member since:
    Aug 2008

    Posted 28 Mar 2015 in reply to Philip Link to this post

    Your solution Philip was a lifesaver.  We have a government form that requires a specific header to only appear on the first page.  For some reason Telerik Reporting has the Report Header print AFTER the Page Header and the blank/empty grouping did the trick.  Thank you for sharing!
  8. Philip
    Philip avatar
    17 posts
    Member since:
    Feb 2014

    Posted 30 Mar 2015 in reply to David A. Link to this post

    Glad to help. Before you get too frustrated with Telerik Reporting, keep in mind that I haven't run up against anything that I could do in Crystal that I can't replicate in Telerik Reporting. Head into your problem assuming there is a way to do it, but you haven't found it yet and you will get there, generally within a couple of hours of thinking and trying different options. Like with subreports. if you're like me, you use many subreports on one report. The general thinking would be to dock the subreports to the top to take up the blank space, but in all actuality, you will just put them one right next to each other and they magically fill in the white space if a subreport is hidden (I spent a couple hours on this one)
  9. David A.
    David A. avatar
    126 posts
    Member since:
    Aug 2008

    Posted 30 Mar 2015 in reply to Philip Link to this post

    I certainly agree that there is always a way to do it with Telerik Reports, and it is the best out of itself, ActiveReports, and CrystalReports.  There are just things that were way easier and much more intuitive in ActiveReports (report header prints before page header, multi-column reports flow L to R) that are only able to be done in Telerik Reports via a hack.
  10. Tim
    Tim avatar
    1 posts
    Member since:
    Oct 2014

    Posted 11 Mar Link to this post

    Problem statement: We need to hide empty sub reports if the entire sub report is empty and if not entirely empty then hide empty panels or sections within the sub report while minimizing white space.

    I am posting how we solved the hiding empty sections and subsequent white space problem in case someone winds up in a similar case.  We followed the advice of several posts about setting the initial height of the details section to 0.  This works in most cases.  In the sub report we had issues with white space where we had about 6 panels stacked on top of each other vertically.  We set their initial heights to 0 and hid them accordingly but the white space still appeared at the bottom of the sub report causing intermittent white space between sub reports as well as generating extra pages as a result.  

    In the detail section item data bound event we used ElementTreeHelper to get all of the direct Panel children of the sub report details section and set their heights to 0.  Then we started an accumulator at 0 and for each visible panel set the top property equal to the accumulator value and then added the visible panel's height to the accumulator.  This effectively re-positions all the visible panels to be adjacent to each other vertically.  But the key for eliminating the white space was to set the Top to 0 for each INVISIBLE panel.  I am assuming that this moves the invisible panel under the visible panel at render time in such a way that the white space where the panel was hidden from is not rendered.  You may suppose that setting the docking to top for the panels in question would make them snap up and shrink the element but I did not have success with that approach.

    As an side, I found it helpful to set colored borders around each panel or sub report to derive how the rendering responds to attempts to control the white space.  I tried various techniques to accomplish this such as bindings, conditional formatting, expressions using =COUNT(Fields.NameOfField) > 0, and the like but nothing else seemed to work or had various quirks.  One issue I had with using an expression on a sub report and setting Parent.Parent.Visible or something similar is it locks the sub report into a specific hierarchy for the functionality to work.  With this solution wherever the sub report is included it will shrink it's panels to the min height.

    So overall our report uses the following approach to hide empty sub reports and possibly panels within those sub reports and shrink all the white space those elements occupied.
    1. In master report constructor set master report detail data bound event to set detail height to 0; set sub report item data bound event for each sub report
    2. In sub report data bound event get detail section and hide if no data.
    3. In any sub reports that need to further hide panels attach item data bound event to the sub report detail and in that event hide panels with no data.
    3. For each visible panel, set top to 0 for first panel or prior panel's top + prior panel's height for subsequent panels.  For each invisible panel set Top to 0
    4. Rejoice

    The hide element if no data algorithm:
    1. Set element height to 0.
    2. Get all child data containing elements (Table, TextBox, HtmlTextBox, whatever yours may be) and check each element to have a value.  
    3. If any value, set element visible = true else set element visible = false.

    We accomplished Step 2 by creating a recursive iterator that uses ElementTreeHelper internally so that I can get all children under a panel, detail, or an element and then use LINQ to filter it to a specific type.  To distinguish between Textboxes used for display that will always have values and thus make the element visible we used a convention based approach where the text box name begins with "EData_".  With this approach we can get just the boxes that are data bound.  So effectively we have Parent.Visible = Parent.Children.Any(x => x.IsDataBound() && x.HasValue());

    I had seen various cautions AGAINST modifying elements in this way during the Telerik.Reporting.Processing phase but at this time have not seen any negative side effects and it seems sometimes this method is endorsed and sometimes it is not.
  11. Stef
    Admin
    Stef avatar
    3036 posts

    Posted 15 Mar Link to this post

    Hello everyone,

    One more approach utilizing the Reporting expression engine that we can suggest is discussed in the How to hide subreports that has no data forum thread and the Collapse the container when hiding child report items KB article.

    I hope this information is helpful.

    Regards,
    Stef
    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
DevCraft banner