[SOLVED] problems with row selection
[SOLVED] problems with row selection
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?
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?
This discussion has been closed.
Replies
which helped. now it seems to work...