Using the HotColumn
component in Vue 3 Configure the Vue 3 data grid's columns, using the props of the HotColumn
component. Define a custom cell editor or a custom cell renderer.
Find out which Vue 3 versions are supported
Declare column settings To declare column-specific settings, pass the settings as hot-column
properties, either separately or wrapped as a settings
property, exactly as you would for hot-table
.
Array of objects To work with an array of objects for the hot-column
component, you need to provide precise information about the data structure for the columns. To do this, refer to the data for a column in properties as data
.
import { defineComponent } from 'vue';
import { HotTable, HotColumn } from '@handsontable/vue3';
import { registerAllModules } from 'handsontable/registry';
import 'handsontable/dist/handsontable.full.css';
// register Handsontable's modules
registerAllModules();
const ExampleComponent = defineComponent({
data() {
return {
hotData: [
{ id: 1, name: 'Table tennis racket', payment: { price: 13, currency: 'PLN' } },
{ id: 2, name: 'Outdoor game ball', payment: { price: 14, currency: 'USD' } },
{ id: 3, name: 'Mountain bike', payment: { price: 300, currency: 'USD' } }
],
secondColumnSettings: {
title: 'Second column header'
},
settings: {
height: 'auto',
licenseKey: 'non-commercial-and-evaluation'
},
};
},
components: {
HotTable,
HotColumn,
}
});
export default ExampleComponent;
import { createApp } from 'vue';
const app = createApp(ExampleComponent);
app.mount('#example2');
<script src="https://cdn.jsdelivr.net/npm/handsontable@13.1/dist/handsontable.full.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/handsontable@13.1/dist/handsontable.full.min.css" />
<script src="https://cdn.jsdelivr.net/npm/vue@3/dist/vue.global.prod.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@handsontable/vue3@13.1/dist/vue-handsontable.min.js"></script>
<script src="https://handsontable.com/docs/13.1/scripts/fixer.js"></script>
<div id="example2">
<hot-table :data="hotData" :settings="settings">
<hot-column title="ID" data="id">
</hot-column>
<hot-column :settings="secondColumnSettings" read-only="true" data="name">
</hot-column>
<hot-column title="Price" data="payment.price">
</hot-column>
<hot-column title="Currency" data="payment.currency">
</hot-column>
</hot-table>
</div>
Last update: Nov 20, 2024