Handsontable example
HTML
<script src="https://cdn.jsdelivr.net/npm/handsontable@12.2/dist/handsontable.full.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/handsontable@12.2/dist/handsontable.full.min.css" />
<script src="https://handsontable.com/docs/scripts/fixer.js"></script>
<div id="exampleParent" class="newNScrollBar"><!-- element with dynamically added styles -->
<div id="example" class="newNScrollBar"></div>
</div>
<div class="controls">
<button id="triggerBtn" class="button button--primary">Expand container</button>
</div>
SCSS
#exampleParent {
height: 157px;
}
.newNScrollBar::-webkit-scrollbar {
width: 7px;
height: 7px;
background-color: rgba(240, 240, 240, 0.7);
}
.newNScrollBar::-webkit-scrollbar-thumb {
background-color: rgba(210, 210, 210, 0.7);
border-radius: 2px;
}
Babel + JSX
import Handsontable from 'handsontable';
import 'handsontable/dist/handsontable.full.min.css';
const triggerBtn = document.querySelector('#triggerBtn');
const example = document.querySelector('#example');
const exampleParent = document.querySelector('#exampleParent');
// generate an array of arrays with dummy data
const data = new Array(100) // number of rows
.fill()
.map((_, row) => new Array(10) // number of columns
.fill()
.map((_, column) => `${row}, ${column}`)
);
const hot = new Handsontable(example, {
data,
rowHeaders: true,
colHeaders: true,
width: '100%',
height: '100%',
rowHeights: 23,
colWidths: 100,
licenseKey: 'non-commercial-and-evaluation'
});
triggerBtn.addEventListener('click', () => {
if (triggerBtn.textContent === 'Collapse container') {
exampleParent.style.height = ''; // reset to initial 150px;
hot.refreshDimensions();
triggerBtn.textContent = 'Expand container';
} else {
exampleParent.style.height = '410px';
hot.refreshDimensions();
triggerBtn.textContent = 'Collapse container';
}
});