multipage selection - i have read faq
multipage selection - i have read faq
I have read through the faq about selecting rows in multi-pages but either I am not getting it or the way I am using it just doesn't work. I am fairly new to datatables so if I have missed something obvious then please play nice.
I have an application that is using a lot of datatables that are created on the fly in response to socket messages.
The only way that I got this construct to work properly was by using nDestroy, which could be why I am having the multi-page problem.
The table itself is oroginally defined as a shell in the main html.
This code works fine for the first page in the table but not for subsequent.
If I try to define the click handler before re-creating the table then it doesn't work at all - I think because of bDestroy.
Can anyone help me get this sorted?
[code]
alertTable=$('#alertsTable').dataTable({
'bDestroy':true,
'aaData': alertData,
'aoColumns': [
{'sTitle':'Date'},{'sTitle':'Text'}
]
}).css('width','');
$('#alertsTable tbody tr').click(function(e){
if ($(this).hasClass('success')) {
$(this).removeClass('success');
}
else {
alertTable.$('tr.success').removeClass('success');
$(this).addClass('success');
};
var rowClicked=alertTable.fnGetPosition( this );
$('#detailPnl').html(dispJSON(onePatient.alerts[rowClicked]));
showDetail();
});
[/code]
I have an application that is using a lot of datatables that are created on the fly in response to socket messages.
The only way that I got this construct to work properly was by using nDestroy, which could be why I am having the multi-page problem.
The table itself is oroginally defined as a shell in the main html.
This code works fine for the first page in the table but not for subsequent.
If I try to define the click handler before re-creating the table then it doesn't work at all - I think because of bDestroy.
Can anyone help me get this sorted?
[code]
alertTable=$('#alertsTable').dataTable({
'bDestroy':true,
'aaData': alertData,
'aoColumns': [
{'sTitle':'Date'},{'sTitle':'Text'}
]
}).css('width','');
$('#alertsTable tbody tr').click(function(e){
if ($(this).hasClass('success')) {
$(this).removeClass('success');
}
else {
alertTable.$('tr.success').removeClass('success');
$(this).addClass('success');
};
var rowClicked=alertTable.fnGetPosition( this );
$('#detailPnl').html(dispJSON(onePatient.alerts[rowClicked]));
showDetail();
});
[/code]
This discussion has been closed.
Replies
Got it on the 6th or 7th read.
I couldn't get the pre-initialisation version to work in any way (still not sure why) but the post-initialisation code worked using fnGetNodes.