views:

38

answers:

1

hey all.. 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;
                }
+1  A: 

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');
});
karim79
yupz....i forgot that..thanks Karim79.
klox