Datatables form - need to get each row's data from form submitted by checkbox selected
Datatables form - need to get each row's data from form submitted by checkbox selected
mc_1
Posts: 2Questions: 0Answers: 0
I have a page that displays a datatable, similar to this on the URL below.
http://datatables.net/examples/api/form.html
What I need is, for each row selected by a checkbox, when it is submitted using the submit button, I need to get hold of the row's data selected based on the checkbox selected.
This is my code below. I want it to be able to output all the field values on the row selected, not just the checkbox value. When I have tried things out, scanning for hidden fields ect it doesn't work.
Can someone tell me how I can get the seleted row's data into the alert message variable "sData" as output below, not just the checkbox value.
[code]
var oTable;
$(document).ready(function() {
// Form Submission
$('#form').submit( function() {
// Will serialize data, but will ignore the input hidden types
var sData = oTable
.find('input')
//.not('input[type=hidden]')
.serialize();
alert( "The following data would have been submitted to the server: \n\n"+sData );
return false;
} );
// Create Data Table - table is called msm
oTable = $('#example).dataTable( {
"aoColumns": [
{ "sWidth": "35%" },
{ "sWidth": "15%" },
{ "sWidth": "15%" },
{ "sWidth": "10%" },
{ "sWidth": "10%" },
{ "sWidth": "10%" },
{ "sWidth": "5%" }],
"bJQueryUI": true,
"sPaginationType": "full_numbers", "aoColumnDefs": [
{ "bSortable": true, "aTargets": [ 0 ] }
],
"aaSorting": [[0, 'asc']]
} );
} );
[/code]
This is an example table row:
${item.item1}
${item.item2}
${item.item3}
${item.item4}
${item.item5}
${item.item6}
http://datatables.net/examples/api/form.html
What I need is, for each row selected by a checkbox, when it is submitted using the submit button, I need to get hold of the row's data selected based on the checkbox selected.
This is my code below. I want it to be able to output all the field values on the row selected, not just the checkbox value. When I have tried things out, scanning for hidden fields ect it doesn't work.
Can someone tell me how I can get the seleted row's data into the alert message variable "sData" as output below, not just the checkbox value.
[code]
var oTable;
$(document).ready(function() {
// Form Submission
$('#form').submit( function() {
// Will serialize data, but will ignore the input hidden types
var sData = oTable
.find('input')
//.not('input[type=hidden]')
.serialize();
alert( "The following data would have been submitted to the server: \n\n"+sData );
return false;
} );
// Create Data Table - table is called msm
oTable = $('#example).dataTable( {
"aoColumns": [
{ "sWidth": "35%" },
{ "sWidth": "15%" },
{ "sWidth": "15%" },
{ "sWidth": "10%" },
{ "sWidth": "10%" },
{ "sWidth": "10%" },
{ "sWidth": "5%" }],
"bJQueryUI": true,
"sPaginationType": "full_numbers", "aoColumnDefs": [
{ "bSortable": true, "aTargets": [ 0 ] }
],
"aaSorting": [[0, 'asc']]
} );
} );
[/code]
This is an example table row:
${item.item1}
${item.item2}
${item.item3}
${item.item4}
${item.item5}
${item.item6}
This discussion has been closed.
Replies