Dynatable broke with dynamic HTML headers

I created Dynatable, I dynamically created table headers. Dynatable gives an error when it starts because it cannot find headers in HTML.

ERROR: Error during collection: could not find column headers in 'thead tr th, etc. If the title bar is different, specify the selector in table: headRowSelector.

CM. FIDDLE: https://jsfiddle.net/0ycqnaxg/6/

It really works if the HTML contains:

Working FIDDLE: https://jsfiddle.net/0ycqnaxg/9/

<thead>
    <th>FirstName</th>
    <th>LastName</th>
  </thead>

But I left thead empty to allow dynamic creation.

+4
source share
2 answers

- Dynatable "thead tr" headRowSelector, "th" . - "thead" headRowSelector.

$('#my-table').dynatable({
    table: {
        headRowSelector:'thead',
    },
    dataset: {
        records: columns
    }
});
+2

Datatables. , . , datatables ;

$('#example thead tr,tfoot tr').append('<th>' + value + '</th>');
+1

All Articles