JavaScript
var
container1 = document.getElementById('example1'),
hot1,
container2 = document.getElementById('example2'),
hot2,
container3 = document.getElementById('example3'),
hot3;
hot1 = new Handsontable(container1, {
data: Handsontable.helper.createSpreadsheetData(3, 7),
colHeaders: true,
dropdownMenu: true
});
hot2 = new Handsontable(container2, {
data: Handsontable.helper.createSpreadsheetData(10, 10),
colWidths: 100,
width: '100%',
height: 320,
rowHeaders: true,
colHeaders: true,
fixedRowsTop: 2,
fixedColumnsLeft: 2
});
hot3 = new Handsontable(container3, {
data: getCarData(),
colHeaders: ['Car', 'Model', 'Registration date', 'Price'],
columns: [
{
type: 'autocomplete',
source: ['Audi', 'BMW', 'Chrysler', 'Citroen', 'Mercedes', 'Nissan', 'Opel', 'Suzuki', 'Toyota', 'Volvo'],
strict: false
},
{
// 2nd cell is simple text, no special options here
},
{
type: 'date',
dateFormat: 'MM/DD/YYYY',
correctFormat: true,
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,
disableDayFn: function(date) {
// Disable Sunday and Saturday
return date.getDay() === 0 || date.getDay() === 6;
}
}
},
{
type: 'numeric',
numericFormat: {
pattern: '$ 0,0.00'
}
}
]
});
function getCarData() {
return [
["Mercedes", "A 160", "01/14/2017", 6999.95],
["Citroen", "C4 Coupe", "12/01/2018", 8330],
["Audi", "A4 Avant", "11/19/2019", 33900],
["Opel", "Astra", "02/02/2020", 7000],
["BMW", "320i Coupe", "07/24/2021", 30500]
...