Referencing 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.
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';
// register Handsontable's modulesregisterAllModules();
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;<div id="example1"> <div class="example-controls-container"> <div class="controls"> <button v-on:click="swapHotData">Load new data</button> </div> </div>
<hot-table ref="hotTableComponent" :settings="hotSettings"></hot-table><br/></div>