Handsontable example

by galvakojis

HTML

<div id="example1" class="hot handsontable htColumnHeaders"></div>
<div id="example2" class="hot handsontable htColumnHeaders"></div>

CSS

</style><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/handsontable.full.min.js"></script><link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/handsontable.full.min.css">

JavaScript

document.addEventListener("DOMContentLoaded", function() {

  function getCarData() {
    return [{
      11: "Mercedes A 160",
      year: 2011,
      1: 7000,
      price_eur: 7000
    }, {
      11: "Citroen C4 Coupe",
      year: 2012,
      1: 8330,
      price_eur: 8330
    }, {
      11: "Audi A4 Avant",
      year: 2013,
      1: 33900,
      price_eur: 33900
    }, {
      11: "Opel Astra",
      year: 2014,
      1: 5000,
      price_eur: 5000
    }, {
      11: "BMW 320i Coupe",
      year: 2015,
      1: 30500,
      price_eur: 30500
    }];
  }

  var
    container = document.getElementById('example1'),
    hot;

  hot = new Handsontable(container, {
    data: getCarData(),
    colHeaders: ["Price"],
    columnSorting: true,
    columns: [{
      data: "1",
      type: "numeric"
    }]
  });



});