Please see my other Telerik report articles.
Use an expression to conditionally display data
In my report, I display social media links for each organizational record.
As you can see, while the data display correctly, it’s layout is static – each row is fixed in position, and when one link is missing (Website), the entire row space is waisted.
Instead of static layout for these rows, I’ll replace both columns of textboxes and static display in favor for a single Html textbox with an expression.
In this expression, I simply repeat an IIf() function for each social media link, to determine if a link is returned (length>=1), then display the label (“Website: “), then the link, or if no link is returned, display blank (nothing).
- Each row displayed begins with a <br>, this ensures the entire row is not displayed or its space is recovered.
- Each IIf() function result is joined with a ‘+’ to build one string for the expression result.
- The control used is an Html textbox – this allows the resulting links to be clickable.
- HtmlDecode() is used to build the links.
Notice now when no link exists, the entire row is reused by links which are returned.
In this example, only two rows are using vertical space in the report instead of four.