Handsontable example
HTML
<script src="https://cdn.jsdelivr.net/npm/handsontable@9.0/dist/handsontable.full.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/handsontable@9.0/dist/handsontable.full.min.css" />
<div id="example1" class="hot "></div>
JavaScript
const container = document.querySelector('#example1');
const cars = ['Audi', 'BMW', 'Chrysler', 'Citroen', 'Mercedes', 'Nissan', 'Opel', 'Suzuki', 'Toyota', 'Volvo'];
const hot = new Handsontable(container, {
licenseKey: 'non-commercial-and-evaluation',
data: [
['Mercedes', 'A 160', '01/14/2021', 6999.95],
['Citroen', 'C4 Coupe', '12/01/2022', 8330],
['Audi', 'A4 Avant', '11/19/2023', 33900],
['Opel', 'Astra', '02/02/2021', 7000],
['BMW', '320i Coupe', '07/24/2022', 30500]
],
colHeaders: ['Car', 'Model', 'Registration date', 'Price'],
height: 'auto',
columns: [
{
type: 'autocomplete',
source: cars,
strict: false,
placeholder: '---'
},
{
placeholder: '---'
// 2nd cell is simple text, no special options here
},
{
type: 'date',
dateFormat: 'MM/DD/YYYY',
correctFormat: true,
placeholder: '-date-',
defaultDate: '01/01/1900',
// datePicker additional options
// (see https://github.com/dbushell/Pikaday#configuration)
datePickerConfig: {
// First day of the week (0: Sunday, 1: Monday, etc)
firstDay: 0,
showWeekNumber: true,
numberOfMonths: 3,
licenseKey: 'non-commercial-and-evaluation',
disableDayFn(date) {
// Disable Sunday and Saturday
return date.getDay() === 0 || date.getDay() === 6;
}
}
},
{
type: 'numeric',
placeholder: '---',
numericFormat: {
pattern: '$ 0,0.00'
}
}
]
});
hot.alter('insert_row', 3)