JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://raw.github.com/warpech/jquery-handsontable/9b29cab8326bcdce6c5c05efe4a9a2932d2e3846/jquery.handsontable.js"></script>
<div id="testTable" class="dataTable"></div>
CSS
/**
* It may be useful to copy the below styles and use on your page
*/
.dataTable {
position: relative;
font-family: Arial, Helvetica, sans-serif;
line-height: 1.3em;
font-size: 13px;
}
.dataTable table {
border-collapse: separate;
position: relative;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-o-user-select: none;
user-select: none;
border-spacing: 0;
}
.dataTable th,
.dataTable td {
border-right: 1px solid #CCC;
border-bottom: 1px solid #CCC;
min-width: 50px;
height: 22px;
line-height: 16px;
padding: 0 4px 0 4px; /* top, bottom padding different than 0 is handled poorly by FF with HTML5 doctype */
}
.dataTable div.minWidthFix {
width: 50px;
}
.dataTable tr:first-child th.htNoFrame,
.dataTable th:first-child.htNoFrame,
.dataTable th.htNoFrame {
border-left-width: 0;
background-color: white;
border-color: #FFF;
}
.dataTable th:first-child,
.dataTable td:first-child,
.dataTable .htNoFrame + th,
.dataTable .htNoFrame + td {
border-left: 1px solid #CCC;
}
.dataTable tr:first-child th,
.dataTable tr:first-child td {
border-top: 1px solid #CCC;
}
.dataTable thead tr:last-child th {
border-bottom-width: 0;
}
.dataTable thead tr.lastChild th {
border-bottom-width: 0;
}
.dataTable th {
background-color: #EEE;
color: #222;
text-align: center;
font-weight: normal;
white-space: nowrap;
}
.dataTable th .small {
font-size: 12px;
}
.dataTable thead th {
padding: 2px 4px;
}
.dataTable th.active {
background-color: #CCC;
}
/* border background */
.dataTable .htBorderBg {
position: absolute;
font-size: 0;
}
.dataTable .htBorderBg.selection {
background-color: #EEF4FF;
}
/* border line */
.dataTable .htBorder {
position: absolute;
width: 2px;
height: 2px;
background: #000;
font-size: 0;
}
.dataTable .htBorder.current {
background: #5292F7;
width: 2px;
height: 2px;
}
.dataTable .htBorder.selection {
background: #89AFF9;
width: 1px;
...
JavaScript
function handsonDeleteRow() {
var table = $("#testTable");
var selected = table.handsontable('getSelected');
if (selected) {
table.handsontable('alter', 'remove_row', selected[0]);
}
}
$(document).ready(function() {
var table = $("#testTable");
table.handsontable({
cols: 5,
minSpareRows: 1,
contextMenu: false,
fillHandle: false,
colHeaders: ["A", "B", "C", "D", ""],
legend: [{
match: function(row, col, data) {
return col === 4;
},
readOnly: true
}]
});
var data = [
["1", "100", "x", "-", "<a href='#' onclick='handsonDeleteRow();return false;'>Delete</a>"],
["2", "20", "y", "-", "<a href='#' onclick='handsonDeleteRow();return false;'>Delete</a>"],
];
table.handsontable("loadData", data, true);
});