Ajax: ignore dot notation

Ajax: ignore dot notation

MayhemMayhem Posts: 1Questions: 1Answers: 0

Hello!

I'm tyring to setup datatables with a rest API. On https://datatables.net/manual/ajax i read that Nested objects can be defined with a dot notation. This is the same format the rest api is using to define a relation.

Example of columns setup:
{ data: 'contact.office.phonenumber' },

So in my dataSrc function I have to shape the data like this:
"contact": { "office": { "phonenumber": "555-1234567" }, },

Now i would like for datatables to ignore the dot notation so i can have a flat array of objects like:
"phonenumber": "555-1234567"

How can i achieve this? Or is this something i have to deal with and all datatables that use this, must have a slightly more complex data structure to achieve my goal?

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @Mayhem ,

    Pretty much what you have in that final line is all that you need. This example here should help, it has an array of objects, like yours, so you just need to map the columns to each element.

    Hope that helps,

    Cheers,

    Colin

This discussion has been closed.