I need to display HTML content in SfRichTextEditor which I'm going to use as a email body creating text editor. The goal is to display the HTML content that I retrieve from an API. From that API, the HTML content comes as a string. So I need to convert that string to a valid HTML code (as a string it has ' ' and ' \" ' characters ).
Before that I have been trying to display HTML content in the SfRichTextEditor by setting the HTMLText property. But it did not work. The final HTML I'm going to display will be a complex HTML (a HTML table with images and text formatting). How can I do this?
This is what I initially tried. But this did not work.
richtexteditor.HtmlText = BuildHTMLContent();
private string BuildHTMLContent()
StringBuilder htmlStr = new StringBuilder("");
htmlStr.Append("<table width='100%' height='20%' Border='1px solid black'>");
htmlStr.Append("<th> FirstName </th>");
We have created a simple sample to reproduce the reported issue with the provided code snippet, but the behavior is working as expected. Please find the sample and video in the below link for your reference.
If our understanding is different from your requirement, could you please provide the following details to investigate further on this issue.
The above details will be more helpful for us to reproduce the issue in our side and assist you with the better solution at the earliest.
Thanks for your reply. Yes it works fine like that.
But when I set a complex html as the HtmlText it shows in a weird way. Is there anyway to disable the scrolling inside the SfRichText editor (webview).
I have attached below the sample with the issue and also I have attached the screenshots of how I need it to look like in a narrow mobile screen (This is how it should be displayed inside SfRichTextEditor).
Please help me to achieve this with SfRichTextEditor.
Currently we do not have support for “Disabling the scrolling inside the SfRichTexteditor”. Based on your requirement we suspect “You want to scroll the Rich text editor at the last line of the text". Could you please confirm us whether this is what you have mentioned as above in your update?.
No that is not what I meant. When the width of the SfRichTextEditor is about the size of width of the phone's display it should look like above screenshots. That means there shouldn't be a horizontal scroll. The content should instead be packed horizontally like how a normal browser displays the content when I resize the browser narrowly like above screenshots. That means SfRichTextEditor should display the HTML content as responsive.
This is how it shows now:
It only shows the half of the content. To see the other part I have to scroll horizontally. But in above screenshots of a normal browser it displays responsive and packed into that size.
We are forwarded the reported query with our internal development team. We will update the further detail, once they provided the suggestion.
On further analysis, we found that we have implemented RichTextEditor control from Content editable DIV which inside the HTML file. The reported issue not related to RichTextEditor control. Where the same issue occurs in content editable DIV also. So, this is the behavior of content editable DIV.
Please find the Simple Content editable DIV sample link: