We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Documenteditor not rendering

DocumentEditorContainer is not showing. Other controls are not showing either. I don't get any errors, control is just not showing


cshtml file:
@Html.EJS().DocumentEditorContainer("container").EnableToolbar(true).Render()

layout file:
 @RenderSection("Scripts", false)

 <!-- Syncfusion Essential JS 2 ScriptManager -->
@Html.EJS().ScriptManager()

web.config:
<add key="UnobtrusiveJavaScriptEnabled" value="false" />

<add namespace="Syncfusion.EJ2"/>

js files:
ej2.min.js is loaded
material.css is loaded

5 Replies

RT Ramya Thirugnanam Syncfusion Team March 5, 2019 12:18 AM

Hi Roy,  
 
Thanks for contacting Syncfusion support.  
 
We are not able to reproduce the reported issue from our side. For your convenience, we have prepared a demo sample for DocumentEditor in ASP.NET MVC 5. Please find the sample from below link.  
 
 
Regards, 
Ramya T 



RV Roy van Es March 5, 2019 04:51 AM

Hello Ramya,

Thank you for the quick reply and the example.
I have looked at the example and when I run this example everything works well. But when trying to get it to work in our application it doesn't show anything. Also simple control like a datepicker isn't working. It is just adding empty tags like this

  <input id="MyFirstDatepicker">
  <documenteditor-container id="container" style="height: 1023px;"></documenteditor-container>
                            
The controls are added in a partial view, maybe this a problem?

Regards,

Roy


RT Ramya Thirugnanam Syncfusion Team March 5, 2019 06:08 AM

Hi Roy,   
 
Could you please provide us the simple sample or code example to replicate the reported issue or to represent your scenario?  This will help us to investigate on the reported issue and provide you the appropriate solution at earliest. 
 
Regards, 
Ramya T 



RV Roy van Es March 11, 2019 03:40 PM

Hello Ramya,

I'm sorry for my late reply. It wasn't possible to send the project as it is a part of a bigger project and the code can't be shared. I figured it out why it was not showing. Because it is loading within a partial view I had to add the following code to the partial view itself

<!-- Syncfusion Essential JS 2 ScriptManager -->
@Html.EJS().ScriptManager()

It is showing but I'm not possible to load a document yet. I added the following line of code in the view, like the example you send me.

@Html.EJS().DocumentEditorContainer("container").ServiceUrl("ap/DocumentEditor/Import").EnableToolbar(true).Render()

at application start we have the following routing in RegisterRoutes

 //ASP.NET Web API Route Config
            routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

And we have a controller

[RoutePrefix("api/documenteditor")]
    public class DocumentEditorController : ApiController
    {
        [HttpPost]
        [Route("Import")]
        public HttpResponseMessage Import()
        {
            if (HttpContext.Current.Request.Files.Count == 0)
                return null;

            HttpPostedFile file = HttpContext.Current.Request.Files[0];
            int index = file.FileName.LastIndexOf('.');
            string type = index > -1 && index < file.FileName.Length - 1 ?
                file.FileName.Substring(index) : ".docx";
            Stream stream = file.InputStream;
            stream.Position = 0;

            EJ2WordDocument document = EJ2WordDocument.Load(stream, GetFormatType(type.ToLower()));
            string json = Newtonsoft.Json.JsonConvert.SerializeObject(document);
            document.Dispose();
            return new HttpResponseMessage() { Content = new StringContent(json) };
        }

        internal static Syncfusion.EJ2.DocumentEditor.FormatType GetFormatType(string format)
        {
            if (string.IsNullOrEmpty(format))
                throw new NotSupportedException("EJ2 DocumentEditor does not support this file format.");
            switch (format.ToLower())
            {
                case ".dotx":
                case ".docx":
                case ".docm":
                case ".dotm":
                    return Syncfusion.EJ2.DocumentEditor.FormatType.Docx;
                case ".dot":
                case ".doc":
                    return Syncfusion.EJ2.DocumentEditor.FormatType.Doc;
                case ".rtf":
                    return Syncfusion.EJ2.DocumentEditor.FormatType.Rtf;
                case ".txt":
                    return Syncfusion.EJ2.DocumentEditor.FormatType.Txt;
                case ".xml":
                    return Syncfusion.EJ2.DocumentEditor.FormatType.WordML;
                default:
                    throw new NotSupportedException("EJ2 DocumentEditor does not support this file format.");
            }
        }

        public string ImportWordDocument(Stream stream)
        {
            string sfdtText = "";
            EJ2WordDocument document = EJ2WordDocument.Load(stream, Syncfusion.EJ2.DocumentEditor.FormatType.Docx);
            sfdtText = Newtonsoft.Json.JsonConvert.SerializeObject(document);
            document.Dispose();
            return sfdtText;
        }



RT Ramya Thirugnanam Syncfusion Team March 12, 2019 04:35 AM

Hi Roy, 
We were unable to reproduce the reported issue.  A support incident to track the status of this defect has been created under your account. Please log on to our support website to check for further updates . 
 
Regards, 
Ramya T 


Loader.
Live Chat Icon For mobile
Up arrow icon