I am trying to use the Handsontable javascript library as a 'real time' CRUD interface to MySQL server. I have created a basic script to load up an instance of Handsontable in a browser and display some test data. See below
<head>
<script src="http://handsontable.com/dist/handsontable.full.js"></script>
<link rel="stylesheet" media="screen" href="http://handsontable.com/dist/handsontable.full.css">
<div id="example"></div>
<script>
var data = [
["", "Ford", "Volvo", "Toyota", "Honda"],
["2014", 10, 11, 12, 13],
["2015", 20, 11, 14, 13],
["2016", 30, 15, 12, 13]
];
var container = document.getElementById('example');
var hot = new Handsontable(container, {
data: data,
minSpareRows: 1,
rowHeaders: true,
colHeaders: true,
contextMenu: true
});
</script>
</head>
However, I am unsure as to how I go about binding Handsontable to a MySQL table to enable real-time manipulation of our data.
Does anyone know how I can go about quickly configuring an instance of Handsontable to achieve this?
Based on your comment, I assume you already have you data in JSON format available on a URL as well as a URL ready to get the data (same format) to upload your database
For what you need to do, you've got pretty much everything explain it this Handsontable documentation example.
You will load your data one time, and save your data in the afterChange event.
Let's take your Handsontable definition and add to it the "realtime" saving function like the example in the documentation :
Below that, let's load the data one time when you open your page :
The key handsontable functions which allow you to load and save your data present in your table are :
If you use jQuery (and I do have a personal preference to Post and Get with it), the equivalent of the ajax function would be :
Again, this assume that you do have the back-end (your PHP code in your case) ready to put and pull data from the interface, but as said in the comment this is completely something else.
If you don't manage to load / save with the above, you may need to check your back-end (connector, your JSON format, etc...) and ask for it on a separate question.