选择单行无功能

发布于 2024-09-10 17:59:28 字数 2265 浏览 5 评论 0原文

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

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;
                }

i have a data table..but it can't select one row after click the row..
can you tell me where the mistake??

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;
                }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千里故人稀 2024-09-17 17:59:28

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

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

I don't know exactly how it is supposed to fit into your code, and your question needs more fleshing out, but I suppose you could select the row next to the clicked one like this:

$("#datalist > tr").click(function() {
    $(this).next("tr").addClass('row_selected');
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文