This page covers a next version of Handsontable, and is not published yet.

This page covers a non-latest version of Handsontable.

# Referencing the Handsontable instance in Vue 2

Table of contents

# Overview

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

# Example

import Vue from 'vue';
import { HotTable } from '@handsontable/vue';
import Handsontable from 'handsontable';

new Vue({
  el: '#example1',
  data: function() {
    return {
      hotSettings: {
        data: Handsontable.helper.createSpreadsheetData(4, 4),
        colHeaders: true,
        height: 'auto',
        licenseKey: 'non-commercial-and-evaluation'
      }
    }
  },
  methods: {
    swapHotData: function() {
      // The Handsontable instance is stored under the `hotInstance` property of the wrapper component.
      this.$refs.hotTableComponent.hotInstance.loadData([['new', 'data']]);
    }
  },
  components: {
    HotTable
  }
});