JSFiddle - React, Tailwind, and code Playground
HTML
<link href="https://unpkg.com/tabulator-tables@5.6.1/dist/css/tabulator.min.css" rel="stylesheet">
<script type="text/javascript" src="https://unpkg.com/tabulator-tables@5.6.1/dist/js/tabulator.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/luxon/build/global/luxon.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Faker/3.1.0/faker.min.js" integrity="sha512-/seDHxVfh1NvFUscAj8GsHQVZJvr2jjAoYsNL7As2FCaFHUHYIarl3sRCvVlFgyouVNiRgHIebyLKjpgd1SLDw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<div id="example-table"></div>
JavaScript
var tabledatahuge = [];
for(var i=1; i <= 15; i++){
tabledatahuge.push({
id:i,
name:faker.name.findName(),
location:faker.name.findName(),
progress:Math.floor(Math.random() * 100) + 1,
rating:Math.floor(Math.random() * 5) + 1,
dob:luxon.DateTime.fromJSDate(faker.date.past()).toFormat("dd/MM/yyyy"),
driver:faker.random.boolean() ? "yes" : "no"
});
}
//Create Date Editor
var dateEditor = function(cell, onRendered, success, cancel){
//cell - the cell component for the editable cell
//onRendered - function to call when the editor has been rendered
//success - function to call to pass thesuccessfully updated value to Tabulator
//cancel - function to call to abort the edit and return to a normal cell
//create and style input
var cellValue = luxon.DateTime.fromFormat(cell.getValue(), "dd/MM/yyyy").toFormat("yyyy-MM-dd"),
input = document.createElement("input");
input.setAttribute("type", "date");
input.style.padding = "4px";
input.style.width = "100%";
input.style.boxSizing = "border-box";
input.value = cellValue;
onRendered(function(){
input.focus();
input.style.height = "100%";
});
function onChange(){
if(input.value != cellValue){
success(luxon.DateTime.fromFormat(input.value, "yyyy-MM-dd").toFormat("dd/MM/yyyy"));
}else{
cancel();
}
}
//submit new value on blur or change
input.addEventListener("blur", onChange);
//submit new value on enter
input.addEventListener("keydown", function(e){
if(e.keyCode == 13){
onChange();
}
if(e.keyCode == 27){
cancel();
}
});
return input;
};
//Build Tabulator
var table = new Tabulator("#example-table", {
height:"415px",
data: tabledatahuge,
columns:[
{title:"Name", field:"name", width:150, editor:"input", editable: false},
{title:"Location",...