row.select() function not working
row.select() function not working
Hi.
I have some dynamically created tables which are populated via ajax call .
$$(targetTable).dataTable( {
//"destroy": true,
"processing": true,
"serverSide": false,
select: {
style: 'multi'
},
"ajax": {
"url": heal_ajax_obj.journals_pub_url,
"data": {
"pub_id": pubid
},
"type":"POST"
},
columnDefs:[{targets:[1], class:"nowrap"},{targets:[2], class:"nowrap"}],
"rowCallback": function( row, data ) {
if ( $.inArray(data.DT_RowId, selected) !== -1 ) {
$(row).addClass('selected');
$$(row).select();
}
},
"createdRow": function ( row, data, index ) {
//var a = parsed.indexOf(data['id']);
if (parsed.indexOf(data['id']) != '-1')
{
$(row).select();
}
}
} );
the thing is that $(row).select() on createdRow does not work. In fact id does nothing.
$(row).addClass('selected') is in fact working but is not the correct way because it causes deselect event not to fire properly.
Even if i try a simple select all rows after the table has been initialized it does not work.
For example :
var table1 = $$(targetTable).DataTable();
table1.row(':eq(0)', { page: 'current' }).select();
this does not work.
I must notice that NOT any JS errors are thrown.
Any ideas?
Replies
Hi @zsimaiof ,
This shows that "simple select" working, so there's no problem there. Given that's not working for you, I suspect you're not including the correct libraries, or possibly in the wrong order. The best bet would be look at my example, compare to yours, and if still no joy, could you modify my one so that it demonstrates your problem,
Cheers,
Colin