我已经从datatable.net插件创建了数据表。数据表以正确的方式生成,但我想进一步获取点击行的数据,我该怎么办? 提前感谢您的帮助。
这里是我提到的创建数据表的链接。 http://datatables.net
这是我的数据表代码
$('#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"
]
}
} );
答案 0 :(得分:4)
参见示例: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
});
});
});