Handsontable example
HTML
<script src="https://cdn.jsdelivr.net/npm/handsontable@14.3/dist/handsontable.full.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/handsontable@14.3/dist/handsontable.full.min.css" />
<script src="https://cdn.jsdelivr.net/npm/numbro@2.1.2/dist/languages.min.js"></script>
<script src="https://handsontable.com/docs/scripts/fixer.js"></script>
<div id="example1" class="hot "></div>
<button class="btn">Get sizes</button>
Babel + JSX
import Handsontable from 'handsontable';
import numbro from 'numbro';
import deDE from 'numbro/languages/de-DE';
import 'handsontable/dist/handsontable.full.min.css';
// register the languages you need
numbro.registerLanguage(deDE);
const container = document.querySelector('#example1');
const hot = new Handsontable(container, {
data: [
{ car: 'Mercedes A 160', year: 2017, price_usd: 7000, price_eur: 7000 },
{ car: 'Citroen C4 Coupe', year: 2018, price_usd: 8330, price_eur: 8330 },
{ car: 'Audi A4 Avant', year: 2019, price_usd: 33900, price_eur: 33900 },
{ car: 'Opel Astra', year: 2020, price_usd: 5000, price_eur: 5000 },
{ car: 'BMW 320i Coupe', year: 2021, price_usd: 30500, price_eur: 30500 },
],
colHeaders: ['Car', 'Year', 'Price ($)', 'Price (€)'],
columnSorting: true,
height: 'auto',
licenseKey: 'non-commercial-and-evaluation',
columns: [
{
data: 'car',
// 1st column is simple text, no special options here
},
{
data: 'year',
type: 'numeric',
},
{
data: 'price_usd',
type: 'numeric',
numericFormat: {
pattern: '$0,0.00',
culture: 'en-US', // this is the default culture, set up for USD
},
allowEmpty: false,
},
{
data: 'price_eur',
type: 'numeric',
numericFormat: {
pattern: '0,0.00 $',
culture: 'de-DE', // use this for EUR (German),
// more cultures available on http://numbrojs.com/languages.html
},
},
],
autoWrapRow: true,
autoWrapCol: true,
manualColumnResize: true
});
let myHidenElement = document.querySelector('.htCore');
function getSizes(){
console.log(hot.getSettings().width) //not defined in settings so it will pass undefined
console.log(window.getComputedStyle(myHidenElement).width)
}
document.querySelector('.btn').addEventListener('click', () => {
getSizes()
})