I have a Sharepoint list, where one of the columns is plain text - Description. When you edit a list item, Description field is normally a TextArea. I have it programmed that this TextArea is extended with JavaScript to accept rich text (html really), so I have my custom rich text field. The problem is that when I input the rich data everything looks fine but when I save the edited item and then display it, the text is displayed as plain text, not html, so instead of a bold text I get "< b >text< /b >". And I would like it to be displayed as html. What can I do with it?
Edit: I don't want to use the built-in editor, because I need some different behavious.
The code that reads in the text input from the form and saves it to the list will be doing a HTMLEncode operation that replaces
< with <
> with >
and so on (look at the source of the page after a save)
This occurs 'server side' so you won't be able to change this using JavaScript.
You've got two options I think
As F5 mentioned you can create a custom field type with your own behaviour for rendering and update. This is the 'correct' way to do this.
You could change your funky javascript to work on a rich text field, hack into the rendering of the built in RTE and replace it with your own.
Of cource as soon as you are taking input from a user and then rendering it back to your web page you open yourself up to all sorts of nasties such as Cross Site Scripting if you are not filtering out potential bad stuff (the very reason why the HtmlEncode is used) - less of a problem in a typical SharePoint site on an Intranet than a public facing site.
SharePoint supports rich text columns using its own in-built editor. You just have to change the column settings so it allows rich text.
If you are using a JavaScript editor because of browser compatability with the built-in rich text editor then SharePoint will always strip the html from whatever is entered as it expects the input to be plain text.
Re your comments
If you want the field to display in rich text it needs to be a rich text field, by setting it to plain text you are always going to lose your custom formatting.
You need to look into custom field types
So where exactly are the data being displayed incorrectly: on the List Display Form or on a Page Layout? If it's on the Page Layout the fix is easy: create a custom Field Control which will retrieve the value of the field (like SPContext.Current.ListItem["YourField"]) and decode the contents to get HTML instead of encoded HTML entities.
Related
I want to add some text (e.g. This is Computer Generated Bill) ONLY on LAST PAGE of Advanced PDF template in Netsuite; where content of page ends . Problem is as number of pages change, text occur on all pages or change its position. Unable to fix this issue.
If you are editing the xml of the freemarker template you can add a custom block of code as the last thing on the page. If you need to make it prominent you can center it and add a bunch of padding above it.
We have a UIWebView within our app to ease the pain of creating a large form. A lot of the text fields produce a keyboard with a "Go" button, but we don't send the user to another page from any text field. A "Done" button would be more appropriate.
In general, is there a way to customize the UIReturnKey on the keyboard, outside of the usual HTML tags?
I need a color image appear when a user views the form in Lotus Notes. I need a black and white version of the same image to appear when the form is being printed.
Is this possible ?
This is (as you probably already have found out) not possible using the standard hide/when options, because you can not only hide when printed.
Instead you should create a print friendly version of the form and create a button that opens the document with the print friendly form when the document must be printed. Have a look at the #Command( [SwitchForm] ; formName ) Formula command for simple form switching.
In the rich text field I choose Full alignment, but when previewed the text has left alignment. When I close and reopen the document, the text is brought back to left alignment.
How can this be resolved?
If I understand you correctly, you have a Notes Form with a Rich Text field, in which you align the text "justified", as in the screenshot below:
But if you view that in a Xpage, the text is no longer justified, neither in the read-only rendering, nor in the edit-rendering with the CKEditor:
Alas, if you align the text justified via the CKEditor, it renders properly in the browser
with an "interesting" rendering in the Notes Client:
This is a "known" problem and in my demo case, the Xpages runtime engine even warns me about that:
"Saving this document will change its format from native Notes rich text to HTML. This may cause a change or loss of formatting if opened again in the regular Notes client."
The conversion of rich text to HTML and vice versa is not the whole problem, even though the message says that. There are also issues with repeated conversions back and forth changeing font sizes, loss of certain colors and styles, etc.
This is a long standing issue with Ben Langhinrichs, who documents that rather thoroughly and even sells an extension to handle that conversions better.
Hope this helps a little bit.
I am using v8.5.3 and in the All Properties of the CKeditor they have a property called 'htmlConversion Warning' that you can set to 'noWarning' which seems to prevent the Saving this document message mentioned above. Seems someone from IBM has taken a note from Microsoft on providing a solution. Now if only they would take a note from them on how to market the product.
I would like to collect your ideas on the following:
SharePoint 2010 (and 2007) does have a preview button... while you are editing a publishing page you can switch to the "Page" tab and hit the Preview button:
Clicking this button does some magic to save your data, and opens a new window where the preview page is displayed. Nice, but could be better. What I would like is live update on editing of field controls from the edit page on the preview page.
My thoughts on this is are as follows:
Field types have an ID. For rendering the field values on your preview page, subclass from the standard FieldValue control, and render a span with the same ID around the field value html. So if we have the text ABC in the content editable div of a RichTextFiled X, render the field value as ABC in the display output (for example using EditModePanels for Display and Edit)
Add key-stroke event handler on all fields for the edit mode page (using for example jQuery), on key press copy contents from edit browser window to preview browser window
Transfer can be done using http://www.sfpeter.com/2008/03/13/communication-between-browser-windows-with-jquery-my-new-plugin/.
Does this sound doable? Would be great to work dual monitor, edit on one monitor, preview page in its real rendering on the other monitor. Especially if the edit mode differs from the display mode.
Looking forward to your input!
I will answer my own question. It is not as easy as its sounds. Fields can use things like reusable content and render patterns. These features render at server side, and change the output. This would require postbacks, which renders the whole thing useless. Lets stay with the already available preview button.