Невозможно добавить опцию таблицы в syncfusion richtexteditor - PullRequest
0 голосов
/ 21 ноября 2018

Я использую компонент syncfusion ej2 richtexteditor для asp.net mvc.Все инструменты работают нормально, но когда я добавляю параметр «таблица» к инструментам, он выдает ошибку в консоли, а панель инструментов не отображается.На консоли появляется следующая ошибка.

Uncaught TypeError: Cannot read property 'id' of undefined
at e.getObject (constants.js:78)
at e.getItems (constants.js:78)
at e.getToolbarOptions (constants.js:78)
at e.render (constants.js:78)
at e.renderToolbar (constants.js:78)
at e.notify (constants.js:78)
at t.notify (constants.js:78)
at t.render (constants.js:78)
at t.appendTo (constants.js:78)
at Contact:130

Вот мой код инициализации в представлении:

@Html.EJS().RichTextEditor("table").ToolbarSettings(e => e.Items((object)ViewBag.tools)).Value((string)ViewBag.value).QuickToolbarSettings(e => { e.Table((object)ViewBag.table); }).ShowCharCount(true).MaxLength(2000).Render()

Код контроллера:

public ActionResult Contact()
    {
        ViewBag.tools = new[] {
            "Bold", "Italic", "Underline", "StrikeThrough",
            "FontName", "FontSize", "FontColor", "BackgroundColor",
            "LowerCase", "UpperCase", "|",
            "Formats", "Alignments", "OrderedList", "UnorderedList",
            "Outdent", "Indent", "|",
            "CreateLink", "Image","table", "|", "ClearFormat", "Print",
            "SourceCode", "FullScreen", "|", "Undo", "Redo"
        };
        ViewBag.table = new[] {
            "Rows", "Columns", "tableCellVerticalAlign"
        };
        ViewBag.value = @"<p>The rich text editor component is WYSIWYG ('what you see is what you get') editor that provides the best user experience to create and update the content. 
                    Users can format their content using standard toolbar commands.</p>
<p><b> Key features:</b></p>

<ul>
    <li><p> Provides & lt; IFRAME & gt; and & lt; DIV & gt; modes </p></li>

    <li><p> Capable of handling markdown editing.</p></li>

    <li><p> Contains a modular library to load the necessary functionality on demand.</p></li>

    <li><p> Provides a fully customizable toolbar.</p></li>

    <li><p> Provides HTML view to edit the source directly for developers.</p></li>

    <li><p> Supports third - party library integration.</p></li>

    <li><p> Allows preview of modified content before saving it.</p></li>

    <li><p> Handles images, hyperlinks, video, hyperlinks, uploads, etc.</p></li>

    <li><p> Contains undo / redo manager.</p></li>

    <li><p> Creates bulleted and numbered lists.</p></li>

</ul>";
        return View();
    }

Может кто-нибудь подсказать, пожалуйстагде я пропускаю трюк.

Ответы [ 2 ]

0 голосов
/ 22 ноября 2018

Поддержка таблиц в EJ2 Rich Text Editor была предоставлена ​​в версии 16.3.21.Обратитесь к заметкам о выпуске для получения дополнительной информации.

Вы можете использовать специфичные для версии файлы CDN, чтобы убедиться в этом.См. Следующие ссылки:

Сценарий: http://cdn.syncfusion.com/ej2/16.3.21/dist/ej2.min.js
Тема: https://cdn.syncfusion.com/ej2/16.3.21/material.css

Чтобы включить таблицы на панели инструментов RTE, необходимо добавить ее в список инструментовкак показано в следующем коде.

[Просмотр]

@Html.EJS().RichTextEditor("default").ToolbarSettings(e => e.Items((object)ViewBag.tools)).Value((string)ViewBag.value).Render() 

[Контроллер]

public ActionResult Index() 
{ 
    ViewBag.value = @"<p>The rich text editor is WYSIWYG ('what you see is what you get') editor useful to create and edit content</p>"; 

    ViewBag.tools = new[] { "Bold", "Italic", "Underline", "StrikeThrough", 
                    "FontName", "FontSize", "FontColor", "BackgroundColor", 
                    "LowerCase", "UpperCase", "|", 
                    "Formats", "Alignments", "OrderedList", "UnorderedList", 
                    "Outdent", "Indent", "|", 
                    "CreateTable", "CreateLink", "Image", "|", "ClearFormat", "Print", 
                    "SourceCode", "FullScreen", "|", "Undo", "Redo" }; 
    return View(); 
}

Убедитесь, что вы включили зависимые сценарии и файлы тем на страницу _layout.cshtml.Для получения дополнительной информации см. Документацию Getting Started

Образец

0 голосов
/ 21 ноября 2018

Я использовал свойство «Таблица» в ViewBag.tools для отображения иконки таблицы.Мне нужно было добавить «CreateTable» вместо таблицы.

...