Reputation: 2896
I have created datatable from datatable.net plugin. datatable generated in right way, but further I want to get the data of clicked row, How should i get? Thank you in advance for your help.
here is the link which i referred to create datatable. http://datatables.net
here is my datatable code
$('#example').dataTable( {
"sDom": "<'row-fluid'<'span6'T><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
"sPaginationType": "bootstrap",
"oLanguage": {
"sLengthMenu": "_MENU_ records per page"
},
"bProcessing": true,
"sAjaxSource": "server/product_status_get_data.php", //setting the server source here
"aoColumns": [
{ "mData": "prd_name" },
{ "mData": "total_doc" },
{ "mData": "promoted" },
{ "mData": "prescribed" }
],
"oTableTools": {
"aButtons": [
"pdf"
]
}
} );
Upvotes: 2
Views: 9320
Reputation: 9370
See sample : http://jsfiddle.net/WapYa/1/
$(document).ready(function() {
$('#example td').live('click', function() {
var anOpen = [];
var nTr = this.parentNode;
var i = $.inArray(nTr, anOpen);
console.log(this); // clicked cell
console.log(nTr); // clicked row
$(this).parent().find("td").each(function() {
console.log($(this).html()); // logs each cell value
});
});
});
Upvotes: 4