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.
- 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.
- 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