Generate Child Row from Nested Object Using Ajax

Generate Child Row from Nested Object Using Ajax

potato_codepotato_code Posts: 14Questions: 5Answers: 0
edited September 16 in Free community support

Hi,

I'm trying to loop through the nested object that contains an array. I am able to successfully render it in the main table as a td but not as a child row (it returns object object). I'm not sure if I'm missing something.

link to test case

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 14,203Questions: 25Answers: 3,354
    Answer ✓

    The value variable is an object, for example: {office: 'London'}. You need to use value.office to have London displayed. See this updated example:
    http://live.datatables.net/rifeheko/4/edit

    Kevin

  • potato_codepotato_code Posts: 14Questions: 5Answers: 0

    Hi,

    Thanks for the reply. It works in the updated example however when I try in my project files a error in the console shows:
    Uncaught TypeError: Cannot read properties of undefined (reading 'location')

    When I try to console.log(d) it comes back as undefined

  • kthorngrenkthorngren Posts: 14,203Questions: 25Answers: 3,354

    Undefined means d doesn't exist in the function. The example has function format(d){...}. Do you have d as the parameter?

    Kevin

  • potato_codepotato_code Posts: 14Questions: 5Answers: 0

    Hi,

    I realized my mistake was that I was referencing the wrong table on td.details-control click.

    Thanks for the help

Sign In or Register to comment.