Can't able to get row data after populating table from JSON data
Can't able to get row data after populating table from JSON data

$(document).ready(function () {
$.getJSON("https://archive.primedice.com/2bd01bb9-7c08-4ac3-b604-41d7fd502632", function( data ) {
var companyTable;
companyTable = $('#data-table').DataTable({
"data" : data,
columns : [
{"data" : "id"},
{"data" : "amount"},
{"data" : "currency"},
{"data" : "statePrimedice.condition"},
{"data" : "payoutMultiplier",
render: function ( data, type, row ) {
return (data).toFixed(2) + "x";
}},
{"data" : "statePrimedice.result",
render: function ( data, type, row ) {
return (data).toFixed(2) + "";
} }
]
});
$('#data-table tbody').on('click', 'tr', function () {
var name = $('td', this).eq().text();
console.log( companyTable.row(this).data()[1]);
$("#json bet id").val(companyTable.row(this).data()[0]);
$("#result").val(companyTable.row(this).data()[5]);
$('#DescModal').modal("show");
});
});
});
can't able to get row.data it keeps giving undefined
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi @deepdice ,
It's because your data is an object - so change
to be
See here.
Cheers,
Colin
Before i was using it as an array ?
You're using
columns.data
and referencing into the array, so I don't understand that.hey can i ask one more thing like i am not able to do this as i am trying to use the cell data in another function but i am only able to access that inside that getBetId() function and not able to render it into cell.