jQuery jexcel breaks input
Using jQuery jexcel breaks value inputs
HTML
<script src="https://bossanova.uk/jexcel/v3/jexcel.js"></script>
<link rel="stylesheet" href="https://bossanova.uk/jexcel/v3/jexcel.css">
<script src="https://bossanova.uk/jtools/v2/japp.js"></script>
<link rel="stylesheet" href="https://bossanova.uk/jtools/v2/japp.css">
<div id="titleDiv"></div>
<div id="worksheet" class="worksheet"></div>
CSS
.worksheet {
width: 100%;
}
.required {
border: 1px dashed #f00 !important;
}
.dummy{}
JavaScript
$('#worksheet').jexcel({
columns: [{
"title": "Origin",
"width": 155,
"align": "left",
"type": "text"
},
{
"title": "Destination",
"width": 191,
"align": "left",
"type": "text"
},
{
"title": "Directionality",
"width": 161,
"align": "left",
"type": "text"
},
{
"title": "Discount Percent",
"width": 146,
"align": "left",
"type": "text"
} ],
columnDrag: false,
columnSorting: false,
columnResize: true,
rowDrag: false,
allowInsertColumn: false,
allowManualInsertColumn: false,
allowDeleteColumn: false,
allowRenameColumn: false,
allowComments: false,
search: false,
onselection: worksheet_OnChange
});
var table = $('#worksheet').get(0).jexcel;
// this line adds the key to the element causing the Object.keys
// check in setValue function to think the cell is a jQuery object.
$('#worksheet table td').data('dummyData', 1);
$('#titleDiv').text('Title DIV text is set');
function worksheet_OnChange(instance, x1, y1, x2, y2) {
$(instance).find('table td.required').removeClass('required');
console.log(table.records[y1][x1]);
var data = $('#worksheet').jexcel('getData', false);
console.log(JSON.stringify(data));
for (var row = 0; row < data.length; row++) {
for (var col = 0; col < data[row].length; col++) {
var cellValue = data[row][col];
console.log(cellValue);
if (cellValue === undefined || cellValue == null || cellValue == '') {
$(table.records[row][col]).addClass('required');
}
}
}
}