handsontable update column name
by fxi
HTML
<div id="hot"></div>
CSS
</style>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/handsontable@latest/dist/handsontable.full.min.css">
<link rel="stylesheet" type="text/css" href="https://handsontable.com/static/css/main.css">
<script src="https://cdn.jsdelivr.net/npm/handsontable@latest/dist/handsontable.full.min.js"></script>
JavaScript
const data = [];
const cols = [];
const gj = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"properties": {
id: 1
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
17.490234375,
26.509904531413927
],
[
15.908203125,
22.998851594142913
],
[
25.839843749999996,
23.079731762449878
],
[
27.773437499999996,
29.152161283318915
],
[
17.490234375,
26.509904531413927
]
]
]
}
},
{
"type": "Feature",
"properties": {
id: 2
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
16.171875,
17.895114303749143
],
[
13.623046875,
7.710991655433217
],
[
24.609375,
6.926426847059551
],
[
25.400390625,
18.729501999072138
],
[
16.171875,
17.895114303749143
]
]
]
}
}
]
}
function getData() {
data.length = 0;
cols.length = 0;
gj.features.forEach(f => {
var hasCols = cols.length > 0;
var p = Object.keys(f.properties).map(p => {
var v = f.properties[p];
if (!hasCols) {
cols.push(p)
}
return v;
})
data.push(p);
});
return data;
}
function setData() {
data.forEach((row, i) => {
row.forEach((val, j) => {
gj.features[i].properties[j] = val;
})
})
window.outgj = gj;
}
getData();
var hotElement = document.querySelector('#hot');
var hotElementContainer = hotElement.parentNode;
var hotSettings =...