RTF fields duplicate RTF coding on second calculation

I am having great difficulty in building a report using RTF fileds and tags.

What i want to achieve is this:

I have a field that is built from a few records through a relationship.
I calculate this using a script to put a line for each records.

  1. so my field injuries_summary is based on

7.1 neck pain, lasting 3 months
7.2 back pain, lasting 5 months
i.e a record for each injury created from the main body of the report.

Thats fine, but if i bring this filed into my final report preview using a display tag for that record then i get my first problem. All carriage returns are ignored unless the user has clicked in the rtf field and changed on character. This is reflected in the data saved in the database, that only becomes rtf after this field is changed in a small way.

  1. My work around for this is to selectall() the text in the element in which the field is contained and then eseentially pasting the field contents into the database field.
forms.injuries_summary_dev.elements.injuries_history.selectAll();
forms.injuries_summary_dev.elements.injuries_history.replaceSelectedText(forms.injuries_summary_dev.rw_injuries_detail)

This now works fine, the database field has RTF in it without clicking in the field and the report preview field brings in the text formatted and with the carriage returns showing.

The problem is that if i now come to recreate this report by building my first subsection preview field again, i get double rtf codes in that field that then messe up the final report.

I do clear the database field out in my script to ‘’, but that doesnt seem to stop this happening.
The only way to prevent it is by clicking in the field on screen and deleting the text from it before rerunning the script.

There seems to be some mismatch between the database field holding the rtf and the element on the screen.

I may have this all very confused, but essentially my work around would be to try to clear the element out in my script before doing the select all bit and repasting the newly contents of the database??? Can i do this and how. selectall() and replace with ‘’ doesnt seem to work.

Otherwise perhaps someone might point out a much more fundamental problem with what i ma doing as i am tighing myself in knots!!!

Thanks

David

I don’t understand 100% what you are doing, but why does it have to be RTF? Couldn’t you just calculate all the related records into one simple string using \n as a carriage return and output that? When using RTF you have to keep in mind that \n is the wrong notation for RTF. You will have to use RTF character entities if the result has to be RTF.

I would always try to avoid RTF. If you need formatting, try html. That’s not perfect either, but much better in my eyes than rtf.

Thanks for that.

The problem is formatting text with bold and larger font size for some parts of the text.

I am sending my final report to PDF, and i dont think or couldnt see that i could get a rendered html view in servoy to allow my users to edit the final preview.

Did sort of solve my problem in that those commands only seem to work if you are actually showing that form, so i just did a qick flick of forms when i ran that subscript and that seems to have sorted it.

Any info on HTML or functions that render text bold or larger font from a method would be well received.

David

Hi David,

dpearce:
Any info on HTML or functions that render text bold or larger font from a method would be well received.

You mean other things than using boldtext , larger and custom font ?
You can use a subset of CSS in your HTML as well.

Its more that i couldnt see a way to show a field in servoy in which once i have created the formatting in my methods, that i could show a preview field with just the formatted text without the tags?

Is there a method of showing the HTML rendered, but in a formatted form without the tags and editable?

Maybe i have missed something basic here?

David

Hi David,

Just like you use the display_type RTF_AREA you can use the display_type HTML_AREA.
And when you enable the Text toolbar you can set the styles and sizes.

Robert,

Now i am annoyed with myself. Was just about to post back saying that it didnt work and i think i did test this a few weeks ago, i suddenly thought that i should put tage in the field and

BINGO it works

Thanks for your help, a much better solution by far.

David