Error thrown when triggering 'draw' event in a datatable in child row (DataTables 1.10)
Error thrown when triggering 'draw' event in a datatable in child row (DataTables 1.10)
RagingTroll
Posts: 34Questions: 3Answers: 0
You can check it here http://jsfiddle.net/E8D9n/6/
[code]//Parent table will attach to 'draw.dt.DT_details' and 'column-visibility.dt.DT_details' events on child.show()
$('#parent').on('draw.dt.DT_details', function(e){
console.log(e);
if(e.namespace != 'DT_details.dt')
alert('namespace: ' + e.namespace + ' is not equal to: DT_details.dt');
});
//Child table will trigger on draw.dt when finished drawing rows
$('#child').trigger('draw.dt');
//test with the correct namespace
$('#child').trigger('draw.dt.DT_details'); //jQuery will create an event with namespace DT_details.dt instead dt.DT_details (jQuery internaly sorts the splitted array, dont know why :S)
//Pseudo code
// var api = $('#parent').DataTable({...});
// api.row(0).child($('', {'id': 'child'}), 'tdclass')
// api.row(0).child.show();
// $('#child').DataTable({...}); //here will be triggered 'draw.dt' event and parent table will catch it ()
//Pasted from dataTable 1.10 source:
/*
table.on('draw' + namespace, function (e) {
table.find('tbody tr').each(function (e) {
if (e.target !== table.get( 0 )) return; //FIX: to ignore draw events from a child table
// Look up the row index for each row and append open row
var rowIdx = _fnNodeToDataIndex(settings, this); //Here rowIdx will be null for the child tr
var row = settings.aoData[rowIdx];
if (row._detailsShow) { //here the exception will be thrown beacuse row will be undefined for the child tr
row._details.insertAfter(this);
}
});
});
*/[/code]
[code]//Parent table will attach to 'draw.dt.DT_details' and 'column-visibility.dt.DT_details' events on child.show()
$('#parent').on('draw.dt.DT_details', function(e){
console.log(e);
if(e.namespace != 'DT_details.dt')
alert('namespace: ' + e.namespace + ' is not equal to: DT_details.dt');
});
//Child table will trigger on draw.dt when finished drawing rows
$('#child').trigger('draw.dt');
//test with the correct namespace
$('#child').trigger('draw.dt.DT_details'); //jQuery will create an event with namespace DT_details.dt instead dt.DT_details (jQuery internaly sorts the splitted array, dont know why :S)
//Pseudo code
// var api = $('#parent').DataTable({...});
// api.row(0).child($('', {'id': 'child'}), 'tdclass')
// api.row(0).child.show();
// $('#child').DataTable({...}); //here will be triggered 'draw.dt' event and parent table will catch it ()
//Pasted from dataTable 1.10 source:
/*
table.on('draw' + namespace, function (e) {
table.find('tbody tr').each(function (e) {
if (e.target !== table.get( 0 )) return; //FIX: to ignore draw events from a child table
// Look up the row index for each row and append open row
var rowIdx = _fnNodeToDataIndex(settings, this); //Here rowIdx will be null for the child tr
var row = settings.aoData[rowIdx];
if (row._detailsShow) { //here the exception will be thrown beacuse row will be undefined for the child tr
row._details.insertAfter(this);
}
});
});
*/[/code]
This discussion has been closed.
Replies
Allan
http://live.datatables.net/IroN/2/edit
Thanks for the test case!
Allan