[SOLVED] problems with row selection

[SOLVED] problems with row selection

sn0bsn0b Posts: 2Questions: 0Answers: 0
edited February 2012 in General
hello,
i am trying to make rows of a table selectable that is populated through server-side processing.
i used the example code from here: http://datatables.net/release-datatables/examples/api/select_single_row.html.
the code for the server side is the 'DataTables server-side script for PHP and MySQL' from the examples in the datatables zip file.

so my code actually looks like this:
[code]
var oTable;

$(document).ready(function() {

$("#documentList tbody tr").click( function(e) {

if ( $(this).hasClass('rowSelected') ) {
$(this).removeClass('rowSelected');
}
else {
oTable.$('tr.rowSelected').removeClass('rowSelected');
$(this).addClass('rowSelected');
}
alert('YEPPA');
});

oTable = $('#documentList').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sPaginationType": "full_numbers",
"sAjaxSource": "list.php"
} );
} );
[/code]

and

[code]



ID
Name
Status
User ID




Loading data from server




ID
Name
Status
User ID



[/code]

but the selection is never done. it seems like [code] $("#documentList tbody tr") [/code] is not able to select the right element. even though if i remove the "tr" it is able to select the table body. but that is not what i need.

any suggestions please?

Replies

  • sn0bsn0b Posts: 2Questions: 0Answers: 0
    ok, i found this post: http://datatables.net/forums/discussion/3753/solved-select-row-and-highlight-with-dblclick-on-second-page/p1

    which helped. now it seems to work...
This discussion has been closed.