Your search did not match any results.

Html Editor - Tables

DevExtreme HTML/Markdown Editor allows users to create and manage tables. This demo illustrates table resize support and table management with the toolbar, context menu, and in code.

Backend API
@section ExternalDependencies { <script src="https://unpkg.com/devextreme-quill@1.7.1/dist/dx-quill.min.js"></script> } @(Html.DevExtreme().HtmlEditor() .ID("html-editor") .Height(750) .Value(new JS("markup")) .TableContextMenu(t => t.Enabled(true)) .TableResizing(t => t.Enabled(true)) .Toolbar(toolbar => toolbar.Items( items => { items.Add().Name(HtmlEditorToolbarItem.Bold); items.Add().Name(HtmlEditorToolbarItem.Color); items.Add().Name(HtmlEditorToolbarItem.Separator); items.Add().Name(HtmlEditorToolbarItem.AlignLeft); items.Add().Name(HtmlEditorToolbarItem.AlignCenter); items.Add().Name(HtmlEditorToolbarItem.AlignRight); items.Add().Name(HtmlEditorToolbarItem.Separator); items.Add().Name(HtmlEditorToolbarItem.InsertTable); items.Add().Name(HtmlEditorToolbarItem.InsertHeaderRow); items.Add().Name(HtmlEditorToolbarItem.InsertRowAbove); items.Add().Name(HtmlEditorToolbarItem.InsertRowBelow); items.Add().Name(HtmlEditorToolbarItem.Separator); items.Add().Name(HtmlEditorToolbarItem.InsertColumnLeft); items.Add().Name(HtmlEditorToolbarItem.InsertColumnRight); items.Add().Name(HtmlEditorToolbarItem.Separator); items.Add().Name(HtmlEditorToolbarItem.DeleteColumn); items.Add().Name(HtmlEditorToolbarItem.DeleteRow); items.Add().Name(HtmlEditorToolbarItem.DeleteTable); items.Add().Name(HtmlEditorToolbarItem.Separator); items.Add().Name(HtmlEditorToolbarItem.CellProperties); items.Add().Name(HtmlEditorToolbarItem.TableProperties); }) ) ) <div class="options"> <div class="caption">Options</div> <div class="option"> @(Html.DevExtreme().CheckBox() .Value(true) .Text("Allow Table Resizing") .OnValueChanged("change_tableResizing") ) </div> <div class="option"> @(Html.DevExtreme().CheckBox() .Value(true) .Text("Enable Table Context Menu") .OnValueChanged("change_tableContextMenu") ) </div> </div> <script> function change_tableResizing(e) { $("#html-editor") .dxHtmlEditor("instance") .option("tableResizing.enabled", e.value); } function change_tableContextMenu(e) { $("#html-editor") .dxHtmlEditor("instance") .option("tableContextMenu.enabled", e.value); } var markup = ` <h2> Hardware Upgrade </h2> <br> <table> <thead> <tr> <th style="text-align: left; width: 320px;">Task Subject</th> <th style="text-align: center;">Status</th> <th style="text-align: right;">Progress</th> </tr> </thead> <tbody> <tr style="text-align: center;"> <td style="text-align: left; width: 320px;">Approve Personal Computer Upgrade Plan</td> <td style="text-align: center; color: #5cb85c;"> <p style="font-size: 1.15em;">✓</p> <p>Completed</p> </td> <td style="text-align: right;">100%</td> </tr> <tr style="text-align: center;"> <td style="text-align: left; width: 320px;">Prepare workspaces</td> <td style="text-align: center; color: #5cb85c;"> <p style="font-size: 1.15em;">✓</p> <p>Completed</p> </td> <td style="text-align: right;">100%</td> </tr> <tr style="text-align: center;"> <td style="text-align: left; width: 320px;">Upgrade Server Hardware</td> <td style="text-align: center;"> <p style="font-size: 1.15em;">⟳</p> <p>In Progress</p> </td> <td style="text-align: right;">45%</td> </tr> <tr style="text-align: center;"> <td style="text-align: left; width: 320px;">Upgrade Personal Computers</td> <td style="text-align: center; color: #f0ad4e;"> <p style="font-size: 1.15em;">‖</p> <p>Need Assistance</p> </td> <td style="text-align: right;">80%</td> </tr> <tr style="text-align: center;"> <td style="text-align: left; width: 320px;">Replace HDD with SSD</td> <td style="text-align: center;"> <p style="font-size: 1.15em;">⟳</p> <p>In Progress</p> </td> <td style="text-align: right;">80%</td> </tr> <tr style="text-align: center;"> <td style="text-align: left; width: 320px;">Purchase a New Server</td> <td style="text-align: center; color: #d9534f;"> <p style="font-size: 1.15em;">✖</p> <p>Canceled</p> </td> <td style="text-align: right;">15%</td> </tr> <tr style="text-align: center;"> <td style="text-align: left; width: 320px;">Purchase Laptops</td> <td style="text-align: center; color: #5cb85c;"> <p style="font-size: 1.15em;">✓</p> <p>Completed</p> </td> <td style="text-align: right;">100%</td> </tr> <tr style="text-align: center;"> <td style="text-align: left; width: 320px;">Prepare a list of necessary devices for testing</td> <td style="text-align: center; color: #5cb85c;"> <p style="font-size: 1.15em;">✓</p> <p>Completed</p> </td> <td style="text-align: right;">100%</td> </tr> <tr style="text-align: center;"> <td style="text-align: left; width: 320px;">Purchase devices for testing</td> <td style="text-align: center; color: #f0ad4e;"> <p style="font-size: 1.15em;">‖</p> <p>Need Assistance</p> </td> <td style="text-align: right;">25%</td> </tr> <tr style="text-align: center;"> <td style="text-align: left; width: 320px;">Recycle Broken Hardware</td> <td style="text-align: center; color: #5cb85c;"> <p style="font-size: 1.15em;">✓</p> <p>Completed</p> </td> <td style="text-align: right;">100%</td> </tr> </tbody> </table> <br> `; </script>
using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Web.Mvc; using DevExtreme.MVC.Demos.Models.SampleData; namespace DevExtreme.MVC.Demos.Controllers { public class HtmlEditorController : Controller { public ActionResult Tables() { return View(); } } }
.demo-container { height: 950px; } .options { padding: 20px; background-color: rgba(191, 191, 191, 0.15); margin-top: 20px; } .caption { font-size: 18px; font-weight: 500; } .option { margin-top: 10px; }

Manage Tables with the Built-in Toolbar

To manage tables via a built-in toolbar, add the following items to it:

  • "insertTable" / "deleteTable"
    Manage a table.

  • "insertRowAbove" / "insertRowBelow" / "deleteRow"
    Manage rows.

  • "insertColumnLeft" / "insertColumnRight" / "deleteColumn"
    Manage columns.

  • "tableProperties" / "cellProperties"
    Open a pop-up window with table or cell customization options.

Manage Tables with the Context Menu

To manage table layouts with the context menu, set the tableContextMenu.enabled property to true. In this demo, you can click the Enable Table Context Menu check box under the HtmlEditor to enable or disable this property. When it is enabled, right-click a table cell to open the context menu.

NOTE

The context menu cannot be used to create new tables. The menu is only available within table boundaries. If you want users to create tables, add an "insertTable" item to the toolbar.

If you need to customize menu commands, override the tableContextMenu.items array. Refer to its description for a code example.

Manage Tables Programmatically

You can perform table-related actions in code. Use the getModule method to access the Table module. This module contains methods with names that match toolbar item names listed above. Refer to the following topic for the complete method list and code examples: DevExtreme Quill modules: Table.

Resize Tables

If you want to resize table rows and columns, set the tableResizing.enabled property to true. In this demo, you can use the Allow Table Resizing check box to change the property value.

You can also set the tableResizing.minColumnWidth and tableResizing.minRowHeight properties to specify minimum column width and row height. If you do not set these properties, width and height are determined by cell content. This demo illustrates the latter behavior (when you reduce column width or row height to small values).