I am very new to using DataTables as well as jQuery.
I am trying to display a table and let the user edit the cells and update the values in the MySQL database.
I don't really understand what the sValue is used for/represents either.
This is my code so far, keeping in mind that I have linked the jeditable.js file.
$(document).ready(function() {
/* Init DataTables */
var oTable = $('#parentEditTable').dataTable({
"columns": [
{
"data": "ParentId"
}, {
"data": "Name"
}],
"order": [[0, 'asc']],
"processing": true,
"serverSide": true,
"responsive": true,
"ajax": {
url: 'processEditParent.php',
type: 'POST'
}
});
oTable.$('#parentEditTable').editable('processEditParent.php', {
"callback": function( sValue, y ) {
var aPos = oTable.GetPosition( this );
oTable.upload( sValue, aPos[0], aPos[1] );
},
"submitdata": function ( value, settings ) {
return {
"row_id": this.parentNode.getAttribute('ParentId'),
"column": oTable.fnGetPosition(this )[2]
};
},
"height": "14px",
"width": "100%"
} );
} );
Any help at all would be appreciated.
I managed to make it work using examples from http://kingkode.com/free-datatables-editor-alternative/ and some of my own code, feel free to comment or ask any questions if you need any help.
Instead of creating a dataSet with static variables, I did a DB query and returned the results as an array and set that array as the dataSet in the dataTable function.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.