Vue Table editor

Vue 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 and Vue 3. 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


Basic example

You can initialize the component via MDBTableEditor.You can pass the data to the component in two ways. First is to bind the data with an array of columns and rows to the dataset property. Second way is to create a HTML markup for your table inside MDBDatatable component - you can customize your table later by adding props to the component. Some of the more advanced options for columns, can be also used by setting data-mdb-attributes directly to a th tag (f.e. <th data-mdb-sort="false">).

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 control disabled state with v-model:edit property binding or by listening to edit and exit events.

Note: search field and add button are not a build-in part of Table Editor.

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".



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.



Dark

Dark mode can be applied to both modal and inline versions - firstly, add a CSS class which changes the background color to your page. Secondly, pass the same class name to the color option of your Table Editor (f.e. 'bg-dark'). Now change the font to light by setting dark attribute to true.

Tip: add form-white class to your search input's wrapper.


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

Vue Table editor - API


Import


        import { MDBTableEditor } from "mdb-vue-table-editor";
      

Properties

Property Type Default Description
actionHeader String 'Actions' Header for action buttons
actionPosition String 'end' Decides where to render an action column (start/end)
bordered Boolean false Adds borders to a datatable
borderless Boolean false Removes all borders from a datatable
borderColor String Changes a border color to one of main colors
cancelText String 'Cancel' Text displayed in cancel buttons
confirm Boolean false Displays a Popconfirm element before removing an entry
confirmText String 'Cancel' Text displayed in confirm buttons (Popconfirm)
confirmMessage String 'Are you sure you want to delete this entry?' Text displayed in a Popconfirm element
color String Adds a color class to a datatable (f.e 'bg-dark')
dark Boolean false Changes a font color to white
defaultValue String "-" This string will be used as a placeholder if a row doesn't have a defined value for a column
dataset Object { columns: [], rows: [] } Main data object
v-model:edit Boolean false Keeps information about edit mode
entries Number 10 Number of visible entries (pagination)
entriesOptions Array [10, 25, 50, 200] Options available to choose from in a pagination select (rows per page)
fixedHeader Boolean false When it's set to true, the table's header will remain visible while scrolling
fullPagination Boolean false Displays additional buttons for the first and last pages
hover Boolean false Changes the background color of a hovered row
loaderClass String "bg-primary" The class name for a loader (loading mode)
loading Boolean false Sets the loading mode - disables interactions and displays a loader
loadingMessage String "Loading results..." A message displayed while loading data
maxHeight [Number, String] Sets a maximum height of a datatable - can be either a string ("10%") or a number of pixels.
maxWidth [Number, String] "100%" Sets a maximum width of a datatable - can be either a string ("10%") or a number of pixels.
mode String 'inline' Changes edit mode - available options: 'inline', 'modal'
multi Boolean false Allows selecting multiple rows (selectable mode)
newItemHeader String 'New item' A header of modal
noFoundMessage String "No matching results found" A message displayed when a table is empty
pagination Boolean true Shows/hides the pagination panel
rowsText String "Rows per page:" A text indicating a number of rows per page
saveText String 'Save Text displayed in the save button (modal)
search String Search phrase
searchColumns Array [] Columns to include while searching. All columns included for an empty array
selectable Boolean false Enables selecting rows with checkboxes
sm Boolean false Decreases a row's paddings
sortField String Default sorted column enabled by a field name
sortOrder String Default sorting order. Available values: "asc" or "desc".
striped Boolean false Slightly changes the background's color in every other row
tag String "div" Defines wrapper tag

Column properties

Name Type Default Description
editable Boolean true Enables/disabled editing fields in this column
label String '' A displayed header of a column
field String label.toLowerCase() A field's name - will be used as a key for values in rows
fixed [Boolean, String] false When set to true, makes a column stick on the left while scrolling. Changing its value to right will do the same on the other side. For this option to work, you need to define width as well.
inputType String 'text' Input type for a column. Available options: 'text', 'number', 'checkbox', 'select'
options Array [] Array of options (for column with a "select" input type)
width Number A column's width in pixels
sort Boolean true Enables/disables sorting for this column
format Array Cell formatting array of objects for each cell.

Methods

Name Description
addRow Adds a new row (default values are optional).

Events

Name Description
add This event fires after adding a new row.
delete This event fires after deleting a row.
edit This event fires when user enters edit mode.
exit This event fires when user exits edit mode.
render Event emitted after the component renders/updates rows.
update This event fires in an editable mode when a user updates values.