选择单行无功能

时间:2010-07-16 03:19:57

标签: jquery datatable row selected

我有一个数据表..但是单击该行后它无法选择一行.. 你能告诉我哪里有错误吗?

oTable = $("#datalist").dataTable({
                                   "bRetrieve"  : true,
                                   "bServerSide": true,
                                   "bProcessing": true,
                                   "sAjaxSource": 'showlist.php',
                                   "fnServerData": function (sSource,aoData,fnCallback){
                        aoData.push({"name":"line","value":$("#showline").val()});
                        aoData.push({"name":"model","value":$("#showmodel").val()});
                        aoData.push({"name":"serial","value":$("#serial").val()});
                        aoData.push({"name":"NIK","value":$("#showNIK").val()});
                        $.ajax({
                                "dataType":'json',
                                "type":'POST',
                                "url":sSource,
                                "data":aoData,
                                "success":function(json){
                                                fnCallback(json);
                                                }
                                });
                        },
                               "aaSorting"  : [[1,"desc"]],
                               "aoColumns"  : [
                                              /*Line*/  null,
                                             /*Model*/ null,
                                            /*Serial*/null,
                                            /*NIK*/   null
                                             ]
                 });
                 }else{
                      oTable.fnDraw();
                       }

              });

              function fnGetSelected( oTableLocal ) {
                        var aReturn = new Array();
                        var aTrs = oTableLocal.fnGetNodes();
                        for ( var i=0 ; i<aTrs.length ; i++ )
                        {
                          if ( $(aTrs[i]).hasClass('row_selected') )
                          {
                           aReturn.push( aTrs[i] );
                           }
                        }
                        return aReturn;
                }

1 个答案:

答案 0 :(得分:1)

我不确切知道它应该如何适合您的代码,而且您的问题需要更多充实,但我假设您可以选择点击的旁边的行,如下所示:

$("#datalist > tr").click(function() {
    $(this).next("tr").addClass('row_selected');
});