How to collapse a list when it has no data

8 posts, 0 answers
  1. Don
    Don avatar
    18 posts
    Member since:
    Feb 2013

    Posted 14 May 2013 Link to this post

    I have a list that sometimes has no data but its full height is blank even when it is empty.

    I've tried conditional formatting and setting visibility to false when there are no items but still whitespace.

    I've tried binding the height of the list to this expression =iif(Fields.PatientCases.Count = 0, ".01in", "1in") but no change.

    Any other suggestions?

    Thanks,
    Don Rule
  2. IvanY
    Admin
    IvanY avatar
    417 posts

    Posted 17 May 2013 Link to this post

    Hi Don,

    You can set the height of the item to 1px for example in the constructor of the report. That way you will be able to work easily in the designer since the height there will not be changed. However in runtime the height will be 1px initially and will become larger only if there is content in it. Please find below the code:
    this.textBox1.Height = new Telerik.Reporting.Drawing.Unit(1.0);

    All the best,
    IvanY
    the Telerik team

    Have you tried the new visualization options in Telerik Reporting Q1 2013? You can get them from your account.

  3. DevCraft banner
  4. Don
    Don avatar
    18 posts
    Member since:
    Feb 2013

    Posted 21 May 2013 Link to this post

    I create my reports i the Designer and then upload them to a database and run them from my web site. It would not be practical to change the web site code in order to adjust the constructor for every new report.

    There must be some way to do it with the Designer. 

    Thanks,
    Don
  5. IvanY
    Admin
    IvanY avatar
    417 posts

    Posted 24 May 2013 Link to this post

    Hi Don,

    In the designer you can simply use bindings, like this (actually you can use this workaround in visual studio too):
    Height                     ='1px'

    Regards,
    IvanY
    Telerik

    Have you tried the new visualization options in Telerik Reporting Q1 2013? You can get them from your account.

  6. Sebastian
    Sebastian avatar
    5 posts
    Member since:
    Sep 2013

    Posted 19 Sep 2013 Link to this post

    This solution does not work.
    I have tried your suggestion both the code behind and the design mode in a binging and I could not get the desired results.

    Code Behind:
    list5.Height = Telerik.Reporting.Drawing.Unit.Pixel(1);

    Binding:
    Height = "1px"

    No solution.

    Please help!
  7. Nasko
    Admin
    Nasko avatar
    909 posts

    Posted 20 Sep 2013 Link to this post

    Hello Sebastian,

    In Telerik Reporting, the default container behavior (such as the List item which contains a Panel item) is to always wrap its children. This means that the Panel will automatically grow if any of the containing items goes outside its bounds. The opposite is not possible - the Panel won't shrink if its content shrinks.

    In order to achieve similar to the required result, we advice you to set the panel and the items inside in design time to have initial size small enough so that they always have to grow.

    Regards,
    Nasko
    Telerik

    Have you tried the new visualization options in Telerik Reporting Q2 2013? You can get them from your account.

  8. Sebastian
    Sebastian avatar
    5 posts
    Member since:
    Sep 2013

    Posted 23 Sep 2013 Link to this post

    Hello Nasko, 

    Thanks for your answer, but I have a problem.
    In design mode, using the binding option and selecting the "Height" property to stablish the size of the list and panel in 1px, in runtime the application throws an exception and it says that the expressión "1px" is not valid.

    How could I solve that?

    Thanks
  9. Nasko
    Admin
    Nasko avatar
    909 posts

    Posted 26 Sep 2013 Link to this post

    Hi Sebastian,

    A little addition: Since you have a Panel item inside a List item, the Panel itself behave like it's docked to the List. Having this in mind, you will need to set both items' heights and the row height of the List to achieve the desired effect. To do that use the following code in the constructor of the report, after the InitializeComponent() method:
    this.panel5.Height = Telerik.Reporting.Drawing.Unit.Pixel(1);
    this.list5.Height = Telerik.Reporting.Drawing.Unit.Pixel(1);
    this.list5.Body.Rows[0] = new TableBodyRow(Telerik.Reporting.Drawing.Unit.Pixel(1));

    Regards,
    Nasko
    Telerik

    Have you tried the new visualization options in Telerik Reporting Q2 2013? You can get them from your account.

Back to Top
DevCraft banner