DEV Community

方帅
方帅

Posted on

How to edit a table's cell with VTable?

Title

Can an editable table enter the editing state directly when clicked, instead of double clicking a cell to make it editable?

Description

In the table editing scenario, double-clicking to enter the editing state would be cumbersome, and you need to enter the editing state directly.

Solution

You can configure editCellTrigger to click in the table initialization option. The configuration item is defined as follows:

/** Edit triggering time: double click event | single click event | api to manually start editing. Default is double click 'doubleclick' */
editCellTrigger?: 'doubleclick' | 'click' | 'api';
Enter fullscreen mode Exit fullscreen mode

Code Example

  const option = {
    records,
    columns,
    autoWrapText: true,
    limitMaxAutoWidth: 600,
    heightMode: 'autoHeight',
    editCellTrigger: 'click' // Set the edit trigger timing
  };
  const tableInstance = new VTable.ListTable(container, option);
Enter fullscreen mode Exit fullscreen mode

Results

Online effect reference: https://visactor.io/vtable/demo/edit/edit-cell

Image description

Related Documents

Edit table demo: https://visactor.io/vtable/demo/edit/edit-cell
Edit table tutorial: https://visactor.io/vtable/guide/edit/edit_cell
Related API: https://visactor.io/vtable/option/ListTable#editCellTrigger
github: https://github.com/VisActor/VTable

Top comments (0)