Error to show details
Error to show details

Hello!!
I'm create a Datatable with RowDetails
Radomly I recive this error:
Uncaught TypeError: Cannot read property '_detailsShow' of undefined
at u.<anonymous> (datatables.min.js:132)
at Function.isShown (datatables.min.js:114)
at HTMLTableCellElement.<anonymous> (monitoralertas.aspx:335)
at HTMLTableElement.dispatch (jquery-1.10.2.min.js:5)
at HTMLTableElement.v.handle (jquery-1.10.2.min.js:5)
This error appears when I click the button (+) on my Grid
Steps:
1) I have a filter section, when I push the button Search this button call to the function Buscar(). I use the filter section to launch the ajax Rq with parameters
..
function Buscar() {
document.getElementById("Datos").style.display = ""; //Poner el stulo del DIV
$('#KPIAlertas').DataTable().clear()
$('#KPIAlertas').DataTable().destroy()
$.fn.dataTable.moment('DD/MM/YYYY H:mm:ss');
var table = $('#KPIAlertas').DataTable({
dom: 'Bfrtip',
buttons: [
'copyHtml5',
'excelHtml5',
'print'
],
"ajax":
{
"url": "./ajax/alertas.ashx",
"type": 'POST',
"data": { "op": "GetAlertas", "a_codi": ObtenerFiltroCliente()}
},
"columns": [
{
"className": 'details-control',
"orderable": false,
"data": null,
"defaultContent": ''
},
{ "data": "Cliente" },
{ "data": "Alerta" },
{ "data": "Fecha" },
{ "data": "ValorTotal", "width": "10", "className": "dt-body-center" },
{ "data": "ValorRegistrado", "width": "10", "className": "dt-body-center" },
{ "data": "Valor", "width": "10", "className": "dt-body-center" },
{ "data": "ActualKPI", "width": "10", "className": "dt-body-center" },
{
"data": function (data, type, row, meta) { if (data.FechaRevisada == "") return false; else return true; }, "width": "10", "className": "dt-body-center",
"render": function (data, type, row, meta) {
if (row.FechaRevisada == "") {
return "<img id=IRes_" + row.id_ale + " src='./img/PRevisada.png' onclick='VerificarAlerta(" + row.id_ale + ",1)' />";
}
else {
return "<img id=IRes_" + row.id_ale + " Title='" + row.FechaRevisada + "'src='./img/Revisada.png' onclick='VerificarAlerta(" + row.id_ale + ",0)'/>"
}
}
}
],
"order": [[1, 'asc']],
"pageLength": 25,
"language": {
"url": "./lang/datatable.json",
buttons: {
copy: 'Copiar',
copyTitle: 'Copiado al portapapeles',
copySuccess: {
_: '%d lineas copiadas',
1: '1 línea copiada'
},
print: 'Imprimir'
}
}
});
// Add event listener for opening and closing details
$('#KPIAlertas').on('click', 'td.details-control', function () {
var tr = $(this).closest('tr');
var row = table.row(tr);
if (row.child.isShown()) {
// This row is already open - close it
row.child.hide();
tr.removeClass('shown');
}
else {
// Open this row
//var childrenHtml = ObtenerHTML(row.data());
ObtenerHTML(row.child, row.data())
// row.child(childrenHtml).show();
tr.addClass('shown');
}
});
}
...
Can you help me?
Answers
I'm facing the same problem. sometimes it works and some times it doesnt.. I am using Javascript sourced data which is a little bit different from your case. Help would be greatly appreciated!
Hello
The solution i find and works fine is put the listener on DocumentReady.
Do you have a working js fiddle demo? Would be helpful.
Hello
Impossible, I use this grid in my intranet website.
Best regards
To anyone having this issue - can you create a test case showing the issue using http://live.datatables.net or JSFiddle please.
Allan
Hi Allan,
Hope you're doing great!
Please find the JSfiddle here: https://jsfiddle.net/rgantla/swjr5oeo/3/
This is a little bit different from my office file where i actually have a problem
I am able to create the child rows show/hide in the fiddle successfully but when I try the same with my office file this error is popping up as shown in the figure (screen cap of my console)
However, the office code I am working with is as follows: Please note that my office script has javascript sourced data (taskData) that I fetched through an ajax call outside of this datatable creation
Just to confirm, the JSFiddle you linked to does not reproduce the issue? I'm afraid I'd really need to be able to see the error to be able to debug it and understand what is triggering it.
Allan
Hi allan,
Thanks for your response. The code I am talking about is secure and I'm afraid I cannot share it here. I have created the JS fiddle now with my office data, which reproduces the error exactly. is there any other way like an email id for us to connect so that I can send the JSfiddle link over to you?
if you feel uncomfortable sharing your email id here, this is my email id: raja.gantla@gmail.com - please ping me on this and we can connect.
I really appreciate your effort. Thanks!
You can send me a PM by clicking my name above and then "send message".
Allan
What is the solution?
I can't remember! Can't you link to a test case showing the issue please.
I have a table that is being loaded with data via ajax. When the data of the table changes, I give a destroy in the table and create it again, but from the third row happens the error:
If you link to a test page showing the issue I'll try to make some time to look into it.
Allan
Okay, but I would not know more or less what might cause this error?
If you link to the page I will be able to debug it and then explain what is going wrong. At the moment I honestly don't have a clue what is going wrong.
Allan
This is the code that feeds the dataTable, when I change the data table data I execute this code:
And there occurs the error:
Perhaps your event handle is still being run somehow? Without a test case, which I've already asked for multiple times, I can't say for sure. I'm afraid I won't be replying again without a test case.
Allan
Hi , I have this problem those days, and i have resolve it use the answer given by sebaspmi. Code is below:
Hope my answer will help.
you should remove your click handler when you destroy the datatable. Your table won't be the same if you rebuild it for new AJAX request.
For anyone still having this problem, the solution that worked for me was to set the click event off before setting it on. For example, if my click event is:
I just needed to add:
The working code being:
I hope it helps