The thing with Rich text data is that the fields are not easily shown in a text column especially if the data contains tables, images or different fonts.
It basically looks a mess as well.
In a notes view your stuck basically - it will only show graphical icons (home made icons in later versions) and text.
So the only solution is to have a hidden computed text version of the rich text field:
bodytext
with a formula like:
REM { http://AdFos.com added this 17 Aug 2007 a text version of the body rich text field for $Searchview use};
@Abstract([TextOnly];100;"";"body")
This will create a text version of the field of the first 100 characters.
A bit less duplication as you are only taking 100 characters. The documents can be refreshed using the handy RefreshAllDocuments .
In a web view you can do the above, but you have more scope as the browser can show what it likes.
If you don't want to refresh all documents you can use an agent to display the text version of the document in a iframe, or even display the body field in an iframe, if the field is enormous you can restrict the size of the iframe to a small area or even have the iframe change size to fit the contents automatically or when a user hovers over it etc
This code will use bodytext if it has been computed or show the rich text in an iframe:
@If(@IsAvailable(bodyText);@Left(bodyText;100);
"<iframe scrolling=no frameborder=0 border=0 width=99% height=20 src='/"+@WebDbName+"/ShowRichText?openagent&unid="+@Text(@DocumentUniqueID)+"&sz=100&fld=body'></iframe>")+
ShowRichText agent code: NB This uses function getvalfromqs
Paste this into an agent's initialise that has target set to None:
Sign it with run as web user ticked to prevent it being a security issue.
' ShowRichText agent
' See http://www.notesninjas.com/#RichTextInView for latest version
' usage
' http://adfos.com/db.nsf/ShowRichText?openagent&unid=00000000&fld=body&sz=50
' will grab the first 50 chars of the body field of the doc with unid 00000000
Print "Content-Type:text/html"
Dim s As New notessession
Dim db As notesdatabase
Set db = s.currentdatabase
Dim doc As notesdocument
Set doc = s.DocumentContext
Print |<BODY margin="0" margin-left="0" marginheight="0" topmargin="0" vspace="0" marginwidth="0" leftmargin="0" hspace="0" marginwidth="0" leftmargin="0" hspace="0" style="margin:0; padding:0 margin-left:0; margin-right:0" >|
qs=doc.Query_String_Decoded(0)
unid=getvalfromqs(qs,"unid")
If unid="" Then
Print "<!-- Error: ShowRichText: &unid= is missing or empty -->"
End 'no unid to use
End If
fld=getvalfromqs(qs,"fld")
sz=getvalfromqs(qs,"sz")
If sz="" Or Isnumeric(sz)=False Then
Print "<!-- Error: ShowRichText: &sz= is missing or not numeric -->"
End ' if sz is 0 or not numeric then end
Else
szchars=Cint(sz)
End If
On Error Goto ErrHdlr
Set doc=db.GetDocumentByUNID(unid)
Dim f As Variant
If fld="" Then
Set f = doc.GetFirstItem("body")
Else
Set f = doc.GetFirstItem(fld)
End If
Print "<font face='century gothic'>"
If f.type=RICHTEXT Then
Print Left$(f.text,sz)
Else
Print Left$(f.values(0),sz)
End If
Print "</font>"
Print "</body>"
Print "</head>"
End
ErrHdlr:
'error of some sort
Print "<!-- Error: ShowRichText: " & Error$ & " at line " & Erl & " -->"
End
To put the rich text in an iframe itself, you can reference the rich text field by creating a new form that shows just the rich text field.
Use a view (ImagesOnly) that has a form formula that uses the new form (ImageOnly) .
In the form put the following in the HTML Head attributes to make sure the field is put in the top left with not margins:
"margin=\"0\" margin-left=\"0\" marginheight=\"0\" topmargin=\"0\" vspace=\"0\" marginwidth=\"0\" leftmargin=\"0\" hspace=\"0\" marginwidth=\"0\" leftmargin=\"0\" hspace=\"0\" style=\"margin:0; padding:0 margin-left:0; margin-right:0\" "
( NB this can also be used to display an image that is in a rich text (lite) field that you have no handle (name or url) to. )
The view column formula could be:
"<iframe src='/"+@WebDbName+"/(ImagesOnly)/"+@Text(@DocumentUniqueID)+"?OpenDocument' width='50' height='50' border=0 frameborder=0 scrolling=no align=left ></iframe>"