datatable: failed to retrieve row data
datatable: failed to retrieve row data
zipper
Posts: 35Questions: 9Answers: 0
I used bellow to display extra contents out of the datatable for a selected row since there were too many fields to fit in the table:
if (json.show_extra_contents) {
$('#tbody1').on('click', function () {
var row = table.row($(this).closest('tr'));
$('#information').empty();
for (var i = 0; i < json.tb_fields.length; i++) {
$('#information').append(json.tb_titles[i] + ': ' + row.data()[json.tb_fields[i]] + '<br>');
}
});
}
and it returned error:
"Uncaught TypeError: Cannot read property 'customer.id' of undefined"
The test case is at 54.199.175.35/5 --> "Customer Mgmt" please help, thanks.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
I made it work by:
Looks like you fixed your issue while I was responding :-)
Kevin
Thanks for the quick response @kthorngren, Actually now I changed the code to:
And now the problem is no matter which row I click, it only shows the contents of the first row. May you take a look at the test case 54.199.175.35/6
I believe that you will need to use the select extension in order for
selected: true
intable.row({selected: true})
to work.Another option, not requiring additional JS, to get the data from the selected row is this:
EDIT: almost forgot you probably need to change your click event to:
.on('click', 'tbody tr', function ()
Kevin
With these together it finally worked. thank you for support Kevin.