Reputation: 57
I used colHeaders property to set headers. but only first five are visible until I paste data of more than 5 columns code:
var dataPrePop =["1","2","3","4","5","6","7","8"]
var container = document.getElementById('example');
var hot = new Handsontable(container, {
colHeaders: dataPrePop,
contextMenu: true
});
Full source code -
var dataPrePop = ["1", "2", "3", "4", "5", "6", "7", "8"]
var container = document.getElementById('example');
var hot = new Handsontable(container, {
colHeaders: dataPrePop,
//minSpareCols: 1,
//minSpareRows: 1,
//rowHeaders: true,
//colHeaders: true,
contextMenu: true
});
body {
margin: 20px 30px;
font-size: 13px;
font-family: 'Open Sans', Helvetica, Arial;
}
a {
color: #34A9DC;
text-decoration: none;
}
p {
margin: 5px 0 20px;
}
h2 {
margin: 20px 0 0;
font-size: 18px;
font-weight: normal;
}
<link href="https://docs.handsontable.com/0.34.4/bower_components/handsontable/dist/handsontable.full.css" rel="stylesheet" />
<script src="https://docs.handsontable.com/0.34.4/bower_components/handsontable/dist/handsontable.full.js"></script>
<h2>Handsontable Basic Example (100x10)</h2>
<p>
Head to <a href="https://handsontable.com" target="_blank">handsontable.com</a> to learn more about Handsontable.
</p>
<div id="example"></div>
Upvotes: 2
Views: 297
Reputation: 6797
I think this will work for you -
if you want you can set minCols
minCols: 8 // -- this will do your job
am creating a working sample for you.
var dataPrePop = ["1", "2", "3", "4", "5", "6", "7", "8"]
var container = document.getElementById('example');
var hot = new Handsontable(container, {
colHeaders: dataPrePop,
minCols: 8,
//minSpareCols: 1,
//minSpareRows: 1,
//rowHeaders: true,
//colHeaders: true,
contextMenu: true
});
body {
margin: 20px 30px;
font-size: 13px;
font-family: 'Open Sans', Helvetica, Arial;
}
a {
color: #34A9DC;
text-decoration: none;
}
p {
margin: 5px 0 20px;
}
h2 {
margin: 20px 0 0;
font-size: 18px;
font-weight: normal;
}
<link href="https://docs.handsontable.com/0.34.4/bower_components/handsontable/dist/handsontable.full.css" rel="stylesheet" />
<script src="https://docs.handsontable.com/0.34.4/bower_components/handsontable/dist/handsontable.full.js"></script>
<h2>Handsontable Basic Example (100x10)</h2>
<p>
Head to <a href="https://handsontable.com" target="_blank">handsontable.com</a> to learn more about Handsontable.
</p>
<div id="example"></div>
#2 way should be using data
In the below sample createSpreadsheetData(5, 8)
handles the number of column and row in the table.
var dataPrePop = Handsontable.helper.createSpreadsheetData(5, 8);
var container = document.getElementById('example');
var hot = new Handsontable(container, {
data: dataPrePop,
//minSpareCols: 1,
//minSpareRows: 1,
//rowHeaders: true,
//colHeaders: true,
contextMenu: true
});
body {
margin: 20px 30px;
font-size: 13px;
font-family: 'Open Sans', Helvetica, Arial;
}
a {
color: #34A9DC;
text-decoration: none;
}
p {
margin: 5px 0 20px;
}
h2 {
margin: 20px 0 0;
font-size: 18px;
font-weight: normal;
}
<link href="https://docs.handsontable.com/0.34.4/bower_components/handsontable/dist/handsontable.full.css" rel="stylesheet" />
<script src="https://docs.handsontable.com/0.34.4/bower_components/handsontable/dist/handsontable.full.js"></script>
<h2>Handsontable Basic Example (100x10)</h2>
<p>
Head to <a href="https://handsontable.com" target="_blank">handsontable.com</a> to learn more about Handsontable.
</p>
<div id="example"></div>
I hope this was helpful to you.
Upvotes: 3