oSettings is null - But this is almost exactly example code?
oSettings is null - But this is almost exactly example code?
snakalang
Posts: 2Questions: 0Answers: 0
Hi all, I might be seriously missing something here but the following code is almost exactly the same as the example code at http://datatables.net/release-datatables/examples/api/select_single_row.html but I'm getting oSettings is null at jquery.dataTables.js line 4979.
The code breaks when I try to do
[code]oTable.$('tr.row_selected').removeClass('row_selected');[/code]
I'm pretty sure sure I'm using the latest version of everything?
Here follows my full code, its very basic.
[code]
var oTable;
$(document).ready(function(){
$('#demo').html('');
$('#example').dataTable( {
"bPaginate": true,
"bLengthChange": false,
"bFilter": false,
"bSort": false,
"bInfo": false,
"bAutoWidth": false,
"bServerSide": false,
"aaData": [
/* Reduced data set */
[ "eng","English" , "This is a message" ],
[ "afr","Afrikaans" , "Hierdie is 'n boodskap" ],
],
"aoColumns": [
{ "sTitle": "Language code" },
{ "sTitle": "Language" },
{ "sTitle": "Display string" },
]
} );
/* Add a click handler to the rows - this could be used as a callback */
$("#example tbody tr").click( function( e ) {
if ( $(this).hasClass('row_selected') ) {
$(this).removeClass('row_selected');
}
else {
oTable.$('tr.row_selected').removeClass('row_selected');
$(this).addClass('row_selected');
}
});
oTable = $('example').dataTable();
});
/* Get the rows which are currently selected */
function fnGetSelected( oTableLocal )
{
return oTableLocal.$('tr.row_selected');
}
[/code]
Thanks
The code breaks when I try to do
[code]oTable.$('tr.row_selected').removeClass('row_selected');[/code]
I'm pretty sure sure I'm using the latest version of everything?
Here follows my full code, its very basic.
[code]
var oTable;
$(document).ready(function(){
$('#demo').html('');
$('#example').dataTable( {
"bPaginate": true,
"bLengthChange": false,
"bFilter": false,
"bSort": false,
"bInfo": false,
"bAutoWidth": false,
"bServerSide": false,
"aaData": [
/* Reduced data set */
[ "eng","English" , "This is a message" ],
[ "afr","Afrikaans" , "Hierdie is 'n boodskap" ],
],
"aoColumns": [
{ "sTitle": "Language code" },
{ "sTitle": "Language" },
{ "sTitle": "Display string" },
]
} );
/* Add a click handler to the rows - this could be used as a callback */
$("#example tbody tr").click( function( e ) {
if ( $(this).hasClass('row_selected') ) {
$(this).removeClass('row_selected');
}
else {
oTable.$('tr.row_selected').removeClass('row_selected');
$(this).addClass('row_selected');
}
});
oTable = $('example').dataTable();
});
/* Get the rows which are currently selected */
function fnGetSelected( oTableLocal )
{
return oTableLocal.$('tr.row_selected');
}
[/code]
Thanks
This discussion has been closed.
Replies
Allan
> oTable = $('example').dataTable();
You are missing a hash at the start of `example` .
Allan