How to create

How to create

spickensspickens Posts: 24Questions: 7Answers: 0

I have a placeholder table...

        <table id="demoGrid" class="table table-striped table-bordered dt-responsive nowrap" >  
            <thead>  
                <tr>  
                    <th>Col1</th>  
                </tr>  
            </thead>  
        </table> 

An an array of objects obtained by ajax.

    var columnsx = 
        [
        { "data": "ExamSeriesCode", "name": "ExamSeriesCode", "autoWidth": true },
        { "data": "NoShow", "name": "NoShow", "autoWidth": true },
        { "data": "NDARefused", "name": "NDARefused", "autoWidth": true },
        { "data": "Tested", "name": "Tested", "autoWidth": true }
    ];

How do I drop the placeholder <th> and create one <th> in #demoGrid for each "data" : "xxxx" element in the array.

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    edited April 2018 Answer ✓

    Hi @spickens ,

    You probably don't need to worry about it. If you look at this example here, you can create the table without the thead, and it all gets filled in for you. It's based on this example, which has some more words explaining it.

    Cheers,

    Colin

  • spickensspickens Posts: 24Questions: 7Answers: 0

    That was the trick. Thank you.

This discussion has been closed.