Design improvements for tables

Posted by: bernhard.bleicher on 29 January 2019, 2:06 am EST

  • Posted 29 January 2019, 2:06 am EST

    Hello,

    i am currently working on reports with tables and looking for some design improvements.

    We tried to create the following design:


    To get this design we had to use empty columns and rows. The columns are needed as we can't apply a padding to the border. The empty row is needed to get more space between the first details row and the border. So my questions are:



    • Is it possible to define an extra space between the header and the first details row? If i use the "padding top" property, this is applied to all detail rows and not only to the first.


    • Is there a better way than using the border in the table header? We didn't want the border to use the full width of the column, as this is not possible, we used empty columns to create some white space.


    • Can we set an alternating background color?


    • Is there a way to automatically resize the columns depending on the content?



    I attached an example project with the report template:Example.zip

    Thanks
  • Replied 29 January 2019, 6:36 pm EST

    Hello,

    >>Is it possible to define an extra space between the header and the first details row?
    Yes, you can use the "padding top" property for the same. You can use the following expression to apply padding-top property in the first row only:
    =IIF(RowNumber()=1,"15pt","0pt")


    >>Is there a better way than using the border in the table header?
    It is not possible. you need to use the extra column to achieve the same.

    >>Can we set an alternating background color?
    Yes, you need to set the following expression to Background Color property to set an alternating color
     =IIF(RowNumber() Mod 2 =0, "Blue", "Red")


    >>Is there a way to automatically resize the columns depending on the content?
    Sorry, there is no direct resize the columns depending on the content. You need to get the size of the largest Text in data set column through "TextRenderer.MeasureText" Method. After that, you need set the width of the column to above resultant size.

    (pr.Report.Body.ReportItems[0] as GrapeCity.ActiveReports.PageReportModel.Table).TableColumns[0].Width = Size of the above largest text;


    Hope it helps.

    Thanks.
  • Replied 30 January 2019, 7:43 pm EST

    Thanks, looks really good. But i had problems using the expressions in stylesheets, the following expression didn't work:
    =IIF(RowNumber()=1,"15pt","0pt")

    Everything else, e.g. the border or a static padding, is set correctly but the expression doesn't work.
    I attached an updated example:
    Example.zip

    Is it possible to also set the "WrapMode" and the "CanGrow" properties from the stylesheet? And if not, is it planned for the future?
  • Marked as Answer

    Replied 1 February 2019, 12:51 am EST

    Hello,

    >>Thanks, looks really good. But i had problems using the expressions in stylesheets, the following expression didn't work:
    I am able to reproduce the problem at my end. I have escalated the issue at my end(ID 269764) and will inform you once I get any information from them.

    As a workaround, could you please change the expression to "=IIF(RowNumber()=2,"15pt","0pt")" and run the report and again change it to =IIF(RowNumber()=1,"15pt","0pt").

    >>Is it possible to also set the "WrapMode" and the "CanGrow" properties from the stylesheet?
    Yes, it is possible to set "WrapMode" through StyleSheet. Just change the "Type" of Stylesheet from "Common" to "Text".

    Regarding "CanGrow", It is not possible to set through StyleSheet. Because Stylesheet is common for page report and rdl report. "CanGrow" and "CanShrink" property is not supported in the PageReport. That's why these properties are not included in Stylesheet.

    Thanks.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels