Submit json when checkbox selected
Submit json when checkbox selected

Hi all,
I'm using a setup similar to this https://editor.datatables.net/examples/api/checkbox.html
Where you select a checkbox, however instead of posting with the POST array data,
I wanted to modify $('#example').on('change', 'input.editor-active', function ( ) { }
So it submits json via XMLHttpRequest() the only issue i'm having is getting the related data
anyone know how to get the correct row index/data?
This discussion has been closed.
Answers
You can probably do something like this:
The
row-selector
docs show the selectors you can use to select the row you want.Kevin
Hi Kevin,
I used this but got "undefined"
var table = $('#example').DataTable();
var row = $(this).closest('tr');
var data = table.row( row ).data();
alert( JSON.stringify(data) );
The code works in this example:
http://live.datatables.net/guwafemu/41/edit
Please update the example to show the problem you are having.
Kevin
OK I can confirm if the editor.edit line is left in and the code follows it, will produce an undefined but I commented mine out as well and it works thanks
I have noticed the active checkbox value does not appear to update though, so when i send it via JSON.stringify() it always has a value of true
Yes that happens. Thought you wanted to remove the POST that occurs in the example. You can use
submitComplete
to get the updated data values after the edit submit in the click event. For example:http://live.datatables.net/guwafemu/42/edit
We will need to see an example of this.
Kevin
Thanks Kevin, I've resolved it setting the data field manually,
Very much appreciated.