Two tables; one of which contains a number of templates for frequently used blocks of text. The field on the form is formatted as either RTF area or HTML area and allows for the document to be typed exactly as it is required.
Have a method that copies the contents of the field.
You are mixing up 2 things
1)-elements. is refering to a GUI element and it is possible to do some actions on this.
2)-there is a javascript entity which is called datapovider which is GUI independent.
First you are selecting text in a GUI element (displaying dataprovider data)
Secondly, when working with “description” you are working with the column data and you are putting this on the clipboard.
These 2 actions are unrelated to each other!
For html/rtf there is a method on the GUI element to recieve the display text only… move sample data on the function getSelectedText on the element…
I have what may be a similar issue, with a desciption field on a form that was previously a RTF_AREA field, but now is a TEXT_AREA field.
The TEXT_AREA field now shows all the rtf symbols in addition to the text that was originally typed into the field when it was a RTF_AREA field. Now that it is a TEXT_AREA field how can I write a method that will loop through all the records and strip out all the rtf characters leaving only the original text that was typed into the field.
I have tried both:
var my_text = elements.description.getSelectedText();
and
var my_text = utils.stringReplaceTags(“%%description%%”, foundset);
I am still not getting this. For example, I have a TEXT_AREA field that now contains:
{\rtf1\ansi
{\fonttbl\f0\fnil Monospaced;\f1\fnil Arial;}
\f1\fs22\i0\b Now is the time.\fs18\b0\par
}
because when “Now is the time.” was entered the field was of displayType RTF_AREA.
All the data in all the records is now engulfed in similar rtf symbols, which is understandable. It appears that there is no way to remove the unwanted symbols, short of manually going through each record and deleting them. Is that correct?
I had somehow thought that rtf was a display only thing, but when I open the same table in Sybase Central and look at the data directly I now see that the rtf symbols are saved to the backend database. I assume the same is true with HTML_AREA fields. So it seems that RTF and HTML fields should never be used when the raw data needs to be exported and later imported into another database.
I am just trying to make sure that I fully understand the difference between interface data and backend saved data (ie. Jan’s above referrence to GUI element vs. dataprovider).
Changing the same field to a HTML field and exporting three records yields the following:
"<html> <head> </head> <body> Now is the time. </body></html>"
"Now is the time."
"{\rtf1\ansi{\fonttbl\f0\fnil Monospaced;\f1\fnil Arial;}\f1\fs22\i0\b Now is the time.\fs18\b0\par}"
The first record, the one that was being displayed at the time I changed the field’s displayType, was changed to HTML. The third record which was originally a RTF field when the data was entered retained its original symbols. So the field displayType setting at the time that data is entered appears to govern what ends up in the back end database. Makes sense when you think about it. Interesting.
Lessons learned: Decide whether a field should be of displayType TEXT_AREA, RTF_AREA, HTML_AREA, etc. and stick with it. Do not change your mind after data has been entered. When deciding on displayType keep in mind how exported data will be used.
I finally got the little conversion problem I was having solved.
Problem: TEXT_AREA field containing both plain text and rtf symbols needed to be converted back to just plain text (across many records).
Solution: Placed a global field named displaytype_rtf on the form with its displayType set to RTF_AREA and then used a loop with the following two lines of code:
This ended up being a good exercise because it gave me a much better understanding of the difference between a field that is listed under “elements” and the same field that is listed under “selectedrecord”.
Thank you for the above suggestions that got me thinking in the right direction.
I found this thread so useful I twisted Dean’s arm to do a little more explaining and post it as a tip. He went one step further and created a flash movie for your viewing pleasure!
Jan Blok:
You are mixing up 2 things
1)-elements. is refering to a GUI element and it is possible to do some actions on this.
2)-there is a javascript entity which is called datapovider which is GUI independent.
First you are selecting text in a GUI element (displaying dataprovider data)
Secondly, when working with “description” you are working with the column data and you are putting this on the clipboard.
These 2 actions are unrelated to each other!
For html/rtf there is a method on the GUI element to recieve the display text only… move sample data on the function getSelectedText on the element…
OK, so I’ve used getSelectedText to set a variable my_Text with the contents of the field or the selected elements that I want. How do I insert that variable into the column (on another form) where I want it to go?
Somewhat related to this, I have a field with html that I’d like to be able to edit and then view, edit and then view.
There doesn’t seem to be a way to toggle the displayType of a field between TEXT_AREA and HTML_AREA via a method? I was thinking of a global method that would that I could have a button call that would toggle whatever field it was associated with. I ended up having two fields with identical locations that have opposing visibility states that I toggle. It has equivalent functionality, but just seems somehow less elegant. Thoughts?
rck:
Somewhat related to this, I have a field with html that I’d like to be able to edit and then view, edit and then view.
There doesn’t seem to be a way to toggle the displayType of a field between TEXT_AREA and HTML_AREA via a method? I was thinking of a global method that would that I could have a button call that would toggle whatever field it was associated with. I ended up having two fields with identical locations that have opposing visibility states that I toggle. It has equivalent functionality, but just seems somehow less elegant. Thoughts?
You can’t change the displayType of a field dynamically. Your solution with two fields is the only way to do it (that I know of). You could also use the SHE plug-in (or bean) to throw up a HTML editing dialog to actually see the formatting…