Multiple child rows

Multiple child rows

sztojkocssztojkocs Posts: 1Questions: 1Answers: 0

Hi There!

I try to datatables child rows with wordpress.
I get the column data with while from mysql database and this is one row.
But one row (record) has one or more subrecords get from the same mysql database with while.
I want to use this child row, but i can't.
Have anyone idea what can i do?

Thank you for your help.

This question has an accepted answers - jump to answer

Answers

  • htwyfordhtwyford Posts: 23Questions: 9Answers: 1
    Answer ✓

    The FAQ states:

    Q. Can I define my columns in Ajax loaded JSON?
    A. This is not currently a native feature in DataTables (although it is likely to be added in future). Instead, you would need to load the JSON data using $.ajax and assign the column definition array using the columns option.

    So you can't load your column headers from JSON; you'd have to define them in the columns property of DataTables:

    columns: [
                    {
                       data: "Field1"
                    },
                    {
                        data: "Field2"
                    },
                    {
                        data: "Field3"
                    }
                ],
    

    As for the rest of the question, if you're talking about nested data sources, there's a great section on that in the DataTables Examples. Here's the one on nested JSON objects, and there's also one on nested arrays. If you can get your JSON to resemble that example, then DataTables should be able to read it.

This discussion has been closed.