2

我已经从 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"
            ]
        }           
    } );
4

1 回答 1

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
    });
 });
});​
于 2012-12-27T09:31:51.360 回答