Vue 3 Data GridReferencing the Handsontable instance in Vue 3

Reference the Handsontable instance from a Vue 3 component to programmatically perform actions such as reloading the data in your data grid.

On this page

Example

The following example implements the @handsontable/vue3, showing how to reference the Handsontable instance from the wrapper component.

Find out which Vue 3 versions are supported


import { defineComponent } from 'vue';
import { HotTable } from '@handsontable/vue3';
import { registerAllModules } from 'handsontable/registry';
import 'handsontable/dist/handsontable.full.css';

// register Handsontable's modules
registerAllModules();

const ExampleComponent = defineComponent({
  data() {
    return {
      hotSettings: {
        data: [
          ['A1', 'B1', 'C1', 'D1'],
          ['A2', 'B2', 'C2', 'D2'],
          ['A3', 'B3', 'C3', 'D3'],
          ['A4', 'B4', 'C4', 'D4'],
        ],
        colHeaders: true,
        height: 'auto',
        autoWrapRow: true,
        autoWrapCol: true,
        licenseKey: 'non-commercial-and-evaluation'
      }
    };
  },
  methods: {
    swapHotData() {
      // The Handsontable instance is stored under the `hotInstance` property of the wrapper component.
      this.$refs.hotTableComponent.hotInstance.loadData([['new', 'data']]);
    }
  },
  components: {
    HotTable,
  }
});

export default ExampleComponent;

There is a newer version of Handsontable available. Switch to the latest version ⟶