im working on a databtable thats displaying data from my sql table. so far everything is displaying great however one of my fields needs to be able to be edited by the user and have that value updated in the database accordingly. I've been looking into multiple ways to do this but they havent been working. I've looked into form inputs,cell().edit() and onBlur from https://datatables.net but havent been able to get them to work. currently i have this for my script.
$(document).ready(function () {
var table = $('#example').DataTable({
serverSide: false,
language: {
searchBuilder: {
title: 'Custom Filter'
}
},
dom: 'Q<"pull-left"f><"pull-right"l>rtip',
ajax: {
url: "{{ url('/test') }}",
type: "GET",
datatype: "text",
data: {
q:"select * from exampleTable",
filename:"examplefile.json",
cacheInterval: 1
}
},
columns: [
{data: 'column1',title: 'column1'},
{data: 'column2',title: 'column2'},
{data: 'column3',title: 'column3'
"fnCreatedCell": function (nTd, oData) {
$(nTd).html("<input class='form-control' id='userInput' value='"+ oData.column3 +"'>");
}},
],
order: [
[0, 'asc']
],
column3 in this case would be the one that shows as form field showing the current data already filled as default but can be changed. my html is in a separate blade with this.
<div class="card">
<div class="card-header">Test Table</div>
<div class="card-body">
<button class="updatebutton"type="submit">Submit</button>
<table id="example" class="table table-striped">
</table>
</div>
</div>
preferably It works like onBlur where they edit the line and as soon as they click off it updates the cell however I'll also take updating off the button click.