1

I do not normally work with crystal, but I have spent nearly 2 days looking for a way to do this.

The problem is that I have a number of lines of text that need to show on a report, but need to cut off after 8 lines and show a 'more' prompt to inform the user that they need to go look at the rest of the details online. This was originally handled by storing the data as individual lines already wrap to size and counting the lines with a formula and conditionally showing a separate 'more' field. They have since added the ability to use html to the text, but this made the current way of doing things wrap incorrectly and show the html mark up.

I wrote a database function to combine the text into a single field and use the HTML text interpretation to display it correctly on 7 other reports that do not limit the text length, and the max line count works great for limiting the text size, I just can't figure out how to show the 'more' prompt when needed.

Any suggestions would be greatly appreciated.

GrumpyGeek
  • 11
  • 2
  • So you have the text field marked 'Can Grow' = true and 'Maximum number of lines" = 8? – craig May 07 '12 at 20:44
  • Yes, and that works fine I just need a way to detect that the comment was truncated to 8 lines so I can add the '*more*' prompt off to the side. – GrumpyGeek May 07 '12 at 21:40

2 Answers2

0

GrumpyGeek,

If your database function now combines the text into a single field does this mean the original way, with the separated lines, is still stored? If so, why not add another calculated field called 'line-count' that tallies the old line-based data?

So you'd still have your new combined HTML field and this new field that you could use to show the 'more' button when 'line-count > x'?

Alternatively, another option might work, but would be a bit touchy. That is to make the formula that shows the more button trigger when the field length exceeds x. The catch is that html mark-up isn't displayed, and heavy use of it would skew the amount of text required before you should show the 'more' button. Put another way, a field with very heavy use of mark-up ( and tags) might force the 'more' button earlier than it should. Unless you could somehow make either your 'line-count' calculated field exclude the mark-up OR make the length calculation do the same.

This would be possible if MSSQL or Crystal Reports could run regex to strip the mark-up.

If NONE of the above works, the only other thing I can suggest is to look into UDFs. Crystal allows you to load an external library that you write. These will read functions you write and show them in the function list inside Crystal. If you do this, then you could easily write a routine that strips the HTML and calculates when the more button should be shown.

Good luck with it.

  • Yes the original data is untouched, but because of the html mark ups the original word wrapping can be very off. The original report used the line count method to do trigger the 'more' label, but with the HTML it shows most of the time and is pretty much useless. – GrumpyGeek May 08 '12 at 13:14
  • I think I will try the UDF approarch and see what I can do. Thanks for the help. – GrumpyGeek May 08 '12 at 13:27
  • Yes UDFs are very powerful and the most likely to solve this well. They just involve a bit more work. You're welcome. – Dylan - INNO Software May 08 '12 at 15:32
0

Ideally, there would be a property of the DB field that would return its displayed line count. Unfortunately, there is no such property.

You could try counting the # of line ending characters (e.g. carriage return, line feed). If they are > 7 then show the hyperlink. In a HTML situation, you have to count ending elements (e.g.

). You could make use of a RegEx UFL to make it easier to identify the elements.

Probably the easiest route is to the DB to calculate the # of lines and return that as another field. Use this field to hide/show the hyperlink.

Community
  • 1
  • 1
craig
  • 25,664
  • 27
  • 119
  • 205
  • Trying to get the line count from data doesn't seem reliable given that the HTML can make individual lines wrap. It would be nice if crystal had a mechanism to indicate that the grow limit had been enforced and the data was truncated. I have proposed stripping the HTML code before storing it. The data comes from another system and we merge it in with ours and forward to other systems (which I am not even sure can handle the HTML). If we did this I could just leave the reports alone... we will see what the project manager decides. Thanks for the help. – GrumpyGeek May 08 '12 at 13:45