Table editor

Bootstrap 5 Table editor plugin

Table Editor is a useful tool for displaying and managing data. The component works similarly to the Datatable (docs) with an additional column for action buttons.

Responsive interactive built with the latest Bootstrap 5. Creates editable tables. Delete or edit rows directly or via modal editor.

Note: Read the API tab to find all available options and advanced customization

Note: Currently, the plugin is only compatible with the basic MDB package imported in UMD format. More about import MDB formats.


Basic example

You can initialize the component on table element by adding table-editor class to its wrapper and data-mdb-table-editor-init attribute. In this version, you don't need any additional JavaScript - set all options as data-mdb-attributes (table settings - wrapper element, column settings - th element).

When edit mode is enabled, the user shouldn't be able to interact with other parts of your website, as it can lead to loss of unsaved changes. You can toggle disable state using edit.mdb.tableEditor and editorExit.mdb.tableEditor events.

Note: search field and add button are not a build-in part of Table Editor, but you can easily initialize those functionalities in the simplest form by adding data-mdb-attributes to them (data-mdb-select, data-mdb-add-entry, and data-mdb-target).

Table Editor collects information from HTML markup to create a data structure - the <table> element will be replaced in the DOM with a different node after component initializes.


Company Address Employees
Smith & Johnson Park Lane 2, London 30
P.J. Company Oak Street 7, Aberdeen 80
Food & Wine Netherhall Gardens 3, Hampstead 12
IT Service Warwick Road 14, London 17
A. Jonson Gallery Oaklands Avenue 2, London 4
F.A. Architects Frognal Way 7, Hampstead 4


Modal

To change the default editing mode (inline) to the modal version, set option mode to "modal". If you use select in your modal make sure to declare defaultValue for that column in order for it to work properly.


Inputs example

Table Editor supports several input types - for example, if you wish to force a user to enter only Boolean values in one column, you can set its inputType to a checkbox.

Supported input types:

  • Text (default)
  • Number
  • Checkbox - displays a checkbox in edit mode and true/false value otherwise
  • Select - additionally requires an array of options

Disable edit

You can disable editing for a column by setting its editable option to false. A user won't be able to change its value in the edit mode.


Confirm delete

If you want to prevent data from being accidentally removed, you can set a confirm option to true. In this case, Table Editor will show a Popconfirm element before removing an entry.



Async data

While awaiting data from API, you can prevent a user from interacting with Table Editor by setting loading option to true.



Custom rows

The add() method takes an optional argument - a row which values will be preloaded into a new entry.

Note: for this particular use, a row has to be an object.

Note: as adding buttons are initialized manually, they won't be automatically disabled in the edit mode.

M.B.

(5 Avenue 26, New York)

Berkley & Clark

(43th Street 12, New York)

D&D Inc.

(14 Street 67, New York)

Thomas & Co.

(2 Avenue 54, New York)



Notifications

In this example, handlers for custom events trigger notifications after adding/deleting/updating an entry.