Uncaught TypeError: Cannot use 'in' operator to search for 'length' in Number Of Returned Files

Uncaught TypeError: Cannot use 'in' operator to search for 'length' in Number Of Returned Files

minhalminhal Posts: 76Questions: 12Answers: 0

Hi,

I am trying to fetch data from a stored procedure in to data tables. For some reason its throwing this error.

Maybe I am doing something wrong.

$(document).ready(function () {
var mesa = $('.datatable').DataTable({
filename: "ReturnReportsCount",
responsive: true,
"bAutoWidth": false, // toggle this depending on how wide you want the table
"ajax": {
"url": "/ReturnedStructuredTgts/GetData",
"type": "GET",
"datatype": "json"
},
"deferRender": true,
"responsive": true,
dom: 'Bfrtip',
"bSort": false,
buttons: [
'excel', 'print'
],
"columns": [
"Number Of Returned Files",
"Percentage Of Returned Files"
]

Answers

  • colincolin Posts: 15,144Questions: 1Answers: 2,586

    Try calling the stored procedure by hand, and debugging there. It won't be an issue with DataTables, it'll be the SQL that you're calling.

    Colin

  • minhalminhal Posts: 76Questions: 12Answers: 0

    Hi Colin,

    "columns": [
    "Number Of Returned Files",
    "Percentage Of Returned Files"
    ]

    Is this the right way to call columns? The stored procedure is working fine.

    Thanks,
    Minhal

  • colincolin Posts: 15,144Questions: 1Answers: 2,586

    Ah, yep, columns is very wrong. You need to declare columns.data, and if that's a string you want in the title, use columns.title,

    Colin

  • minhalminhal Posts: 76Questions: 12Answers: 0

    Hi Colin,

    I tried in this way but it's still not working.

    "columns": [
    { "data": "Number Of Returned Files" },
    { "data": "Percentage Of Returned Files" }
    ]

    I have tried in this way as well

    "columns": [
    { "title": "Number Of Returned Files" },
    { "title": "Percentage Of Returned Files" }
    ]

    both the ways are not working for me at the moment.

    Thanks,
    Minhal

  • kthorngrenkthorngren Posts: 20,302Questions: 26Answers: 4,769
    edited January 2020

    Can you post a sample of the JSON response from the browser's developer tools?

    This technote will show you how.

    We will need to see what is returned in order to help. Or you can use the Debugger and provide the code to the developers so they can take a look.

    Kevin

  • minhalminhal Posts: 76Questions: 12Answers: 0

    Hi Kevin,

    There is no error on the console window.

    Thanks,
    Minhal

  • colincolin Posts: 15,144Questions: 1Answers: 2,586

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.