How to check the length of an array in expression editor

0 Answers 622 Views
Conditional Formatting Expressions PictureBox
Rick Feuer
Top achievements
Rank 1
Rick Feuer asked on 21 Jun 2021, 11:58 PM

I want to set up a conditional format to hide an image if the byte array count < 2. I cannot figure out how to simply deal with collections such as arrays and get a count.

I've tried this, but my report won't preview in the designer:

= Count(=Fields.[Logo])

How do I achieve this?

Thanks in advance.

Dimitar
Telerik team
commented on 22 Jun 2021, 12:38 PM

The equals sign should only be used at the start of the expression(unless you need to actually check for equality in the expression), there is no need to also have it before Fields.[Logo] so the expression could be changed to the following: =Count(Fields.[Logo]).

With that being said, you could instead try to get the Length property of the array - Fields.[Logo].Length

Rick Feuer
Top achievements
Rank 1
commented on 22 Jun 2021, 05:12 PM

Thank you that is very helpful. I was trying to check that my length was valid in order to show a picture box in the conditional formatting, but even when my length is < then a number I still see a red box saying 'invalid image data'. Is there a better way to achieve not showing the pic box if there is no image data?
Rick Feuer
Top achievements
Rank 1
commented on 22 Jun 2021, 06:38 PM

It looks like no matter what the picture box has to be bound to a valid image or you'll get the big red box error, so I just created my own function that returns an empty image if the current one is not valid and use that in the Logo property to ensure a valid image is always returned
Dimitar
Telerik team
commented on 24 Jun 2021, 12:22 PM

Indeed, currently, if the PictureBox has an invalid value, it will error out. Creating a user function that always returns a valid image, is what I would also recommend in this case.

You may be interested in the following feature requests:

Allow disabling picturebox errors via "ShowErrors = false"

Show a picturebox of which the url is unavailable as a red cross instead of destoying the complete report layout.

No answers yet. Maybe you can help?

Tags
Conditional Formatting Expressions PictureBox
Asked by
Rick Feuer
Top achievements
Rank 1
Share this question
or