如何在Jquery数据表中选择一行

xyz*_*xyz 9 javascript jquery datatables

我使用的数据表在我的应用程序.每当用户点击我要突出显示的任何行并从所选行中选择一些值时.

"oTableTools": {
               "sRowSelect": "single",

               "fnRowSelected": function ( node ) {
                   var s=$(node).children();
                       alert("Selected Row : " + $s[0]);
                   }
Run Code Online (Sandbox Code Playgroud)

我试过 sRowSelectfnRowSelected,但没有运气.该行未突出显示,也fnRowSelected 未调用.即使控制台上没有错误.

这是我的完整代码

  var userTable = $('#users').dataTable({
            "bPaginate": true,
            "bScrollCollapse": true,
            "iDisplayLength": 10,
            "bFilter": false,
            "bJQueryUI": true,
            "sPaginationType": "full_numbers",
            "oLanguage": {
                "sLengthMenu": "Display _MENU_ records per page",
                "sZeroRecords": "Enter a string and click on search",
                "sInfo": "Showing _START_ to _END_ of _TOTAL_ results",
                "sInfoEmpty": "Showing 0 to 0 of 0 results",
                "sInfoFiltered": "(filtered from _MAX_ total results)"
            },
            "aaSorting": [[ 0, "asc" ]],
            "aoColumns": [/* Name */ null,
                          /*Institution*/null,
                          /*Email*/null],
           "oTableTools": {
               "sRowSelect": "single",

               "fnRowSelected": function ( node ) {
                 alert("Clicked");
                   }
           }       
        });    
Run Code Online (Sandbox Code Playgroud)

我错过了什么吗?

编辑:
现在能够突出显示选定的row.Added class ="display"到HTML表格.仍然想知道为什么我没有在datatable文档中找到它.现在看看如何收集选定的值.

Dan*_*iel 5

我就是这样做的

只需将此功能添加到您的页面(如果用户是您的表ID)

$("#users tbody").delegate("tr", "click", function() {
var iPos = userTable.fnGetPosition( this );
if(iPos!=null){
    //couple of example on what can be done with the clicked row...
    var aData = userTable.fnGetData( iPos );//get data of the clicked row
    var iId = aData[1];//get column data of the row
    userTable.fnDeleteRow(iPos);//delete row

}
Run Code Online (Sandbox Code Playgroud)