documenteditor.editor.insertField


help needed 

i currently using version 19.4.0.38 

and i am trying to insert a mergefield


in vbhtml view

 <div id="documenteditor_container_body" style="display: flex;position:relative">

                @Html.EJS().DocumentEditor("container").IsReadOnly(False).EnableOptionsPane(True).EnableSelection(True).EnableComment(True).Height("700px").Render()

            </div>

in script

 documenteditor = document.getElementById('container').ej2_instances[0];

  documenteditor.editor.insertField('MERGEFIELD ' + fieldName + ' \\* MERGEFORMAT');


but the script crashes on hitting the above line at insertfield


any suggestions please



4 Replies

SM Suriya Murugan Syncfusion Team January 31, 2022 08:35 AM UTC

Hi Rene,


From your provided code snippet, we suspect that reported issue because of you missed to enable editor. Please check below code snippet:

<div style="display:block;width:100%;height:500px">

              @Html.EJS().DocumentEditor("container").IsReadOnly(false).EnableEditor(true).EnableOptionsPane(true).EnableSelection(true).EnableComment(true).Height("700px").Created("onCreated").Render()

           

        </div>

    </div>

</div>

<script>

 

  

 

    var documenteditor;

 

    function onCreated() {

        documenteditor = document.getElementById("container").ej2_instances[0];

        var fieldName='field';

          documenteditor.editor.insertField('MERGEFIELD ' + fieldName + ' \\* MERGEFORMAT');

        documenteditor.resize();

    }

 



Working sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/DocumentEditor-sample1606328107


For your information, Document editor provides just the main document view area. Here, the user can compose, view, and edit the Word documents. You may prefer to use this component when you want to design your own UI options for your application.


Document editor container provides the main document view area along with the built-in toolbar and properties pane.


Regards,

Suriya M.



RE René January 31, 2022 07:38 PM UTC

Solved with the measures i took on my newtonsoft issue, with the different version it worked


thanks



SM Suriya Murugan Syncfusion Team February 1, 2022 09:06 AM UTC

Thanks for your update.



RE René replied to Suriya Murugan February 10, 2022 09:03 AM UTC

Thanks for the help.


its working now


best regards


Loader.
Up arrow icon