JSON data passed to routine - results in no data available

JSON data passed to routine - results in no data available

timobarretttimobarrett Posts: 3Questions: 1Answers: 0

Not publicaly available

code that should display the datatable:
this.dtapi = this.config.container.find('.calldetailgrouptable').DataTable({
data : this.config.data,
columns: [
{data: 'ctime'},
{data: 'cidname'},
{data: 'cidnum', render: UO.prettyphone},
{data: 'type'},
{data: 'hangupcause', render: this.statusRender},
{data: 'tts', render: function(data, type, row) {return me.ttsRender.call(me, data, row);}},
{data: 'length', render: UO.prettytime},
{data: 'holdcount'},
{data: 'holdtime', render: UO.prettytime},
{data: 'mvp', render: this.mvpRender},
{data: 'recfilename'},// render: function(data, type, row) {return me.mkAudioLink.call(me, data, row);}},
{data: 'servicelevel', visible: false}
],
drawCallback: function() {
me.drawCallback.call(me);
},
dom: 'Bftrip',
buttons: [
'pageLength',
{extend: 'print', title: 'Call Detail', exportOptions: popts},
{extend: 'csv', filename: 'call-detail', exportOptions: xopts},
{extend: 'excel', filename: 'call-detail', exportOptions: xopts},
{extend: 'pdf', filename: 'call-detail', title: 'Call Detail', pageSize: 'LETTER',
orientation: 'landscape', exportOptions: xopts},
{extend: 'copy', exportOptions: xopts}
]
});
Error messages shown:
Datatable draws with message "No Data Available in message"

Description of problem:
Data is collected from a number of locations. All data for each location is stored as a row in an array. The final array is json encoded and when a field on my javascript page is clicked. The data is passed to the script that presents the datatable. The data appears to be in the correct format when viewed with the network tab of the developer tools. The data is wrapped in with a "data:" tag. Data is retrieved from a mysql database on each remote site. Json format for the data is "name": "value".

Have reviewed examples in this forum. Datatables debugger says that I'm running version 1.10.12.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,160Questions: 26Answers: 4,921

    What is data : this.config.data,? Is this.config.data an array of objects or a string? It should be an array of objects with the objects being the structure you defined in columns.data.

    If you still need help then maybe you can build a simple test case with an example of this.config.data as Javascript data. Or you can try the Debugger and give the developers the debug code to look at.

    Kevin

  • timobarretttimobarrett Posts: 3Questions: 1Answers: 0

    The data is an array of json objects. Each object contains multiple records per location. data format is {"data":[{"ctime":"2020-05-18 10:01:01","type":"ORDER","hangupcause":"normal","tta":null,"length":"12","holdcount":"0","holdtime":"0","mvp":"0","channel":"SIP","prefix":"24","cidname":"Mary Barry","cidnum":+12105551212","recfilename":"abc.mp3","tts":"7","servicelevel":"good","skilllevel":null},]}

  • kthorngrenkthorngren Posts: 21,160Questions: 26Answers: 4,921
    Answer ✓

    The data you posted is invalid. Its missing a " here ,"cidnum":+12105551212". It should be ,"cidnum":"+12105551212".

    Did you use the browser's debugger or use console.log( typeof this.config.data ) to confirm that is an object and not a string?

    I took are data snippet, fixed the error and removed all of the columns.render statements and your data loads:
    http://live.datatables.net/lonowupa/1/edit

    Not sure what some of your render statements are doing. Check your browser's console for errors.

    Kevin

  • timobarretttimobarrett Posts: 3Questions: 1Answers: 0

    I confirmed that the data was an array by examining the variable in the chrome dev tools. I appreciate your assistance.

This discussion has been closed.