<!--
Error: Cannot create new column. When data source is an object, you can only have as many columns as defined in the first data row, data schema, or in the 'columns' setting.
If you want to be able to add new columns, you have to use an array data source.
-->
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/handsontable/dist/handsontable.full.min.css"
/>
<script src="https://cdn.jsdelivr.net/npm/handsontable/dist/handsontable.full.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/moment@2.29.4/moment.min.js"></script>
<div class="mt-3">
<h2 id="dadoslab">Laboratory Data</h2>
<button type="button" class="m-3 btn btn-primary" id="add-test">Add test</button>
<div class="container">
<div id="exam-table-container"></div>
</div>
<button type="button" class="m-3 btn btn-primary" id="add-test-2">Add test</button>
<input type="hidden" name="handsontable_data" id="handsontable_data">
</div>
<script>
document.addEventListener("DOMContentLoaded", function() {
const container = document.getElementById('exam-table-container');
// Initial data definition as a two-dimensional array
const data = [
['test Date'],
['test'],
];
// Handsontable initialization
const hot = new Handsontable(container, {
data: data,
colHeaders: function (colIndex) {
if (colIndex === 0) {
return 'Exam'; // Header for the first column
}
return `Exam ${colIndex}`; // Dynamic headers for other columns
},
columns: [
{ readOnly: true },
{
type: 'date',
dateFormat: 'DD/MM/YYYY',
correctFormat: true,
defaultDate: moment().format('DD/MM/YYYY'),
datePickerConfig: {
firstDay: 1, // Monday
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.