Deep Objects Example - Ajax Structure

Deep Objects Example - Ajax Structure

qu1ckdryqu1ckdry Posts: 1Questions: 1Answers: 0

Hi,

I'm following the deep objects example here:
https://datatables.net/examples/ajax/deep.html

and I can get everything running fine with the example data. However when trying to integrate my own data I'm having an issue. The given Ajax data format is:

{
  "data": [
    {
      "name": "Tiger Nixon"
    }
 ]
}

with the columns defined as:

"columns": [
            { "data": "name" }
]

My data has the same layout but I have a different root name

{
  "root": [
    {
      "name": "Tiger Nixon"
    }
 ]
}

with the columns defined as:

"columns": [
            { "root": "name" }
]

Is the "data" keyword fixed? Or is it just default and I need to reassign it somewhere?

The error I receive is: "Uncaught TypeError: Cannot read property 'length' of undefined" which I take to mean it can't find the object it's trying to get the property of.

Thanks for any help!!

This discussion has been closed.