colspan on dynamically loaded content

colspan on dynamically loaded content

kiwiskiwis Posts: 15Questions: 10Answers: 0
edited May 2021 in DataTables

I'm using this approach

https://datatables.net/forums/discussion/comment/190137/#Comment_190137

And I have two for loops into my fetch result.

First one is a head row. Second one is my normal data.

Currently all is going well. My issue is on my head template I can't have

<script id="refRow" type="text/html">
    <tr>
        <th colspan="4" data-order="{{Surname}}">{{personName}}</th>
    </tr>
</script>

In my HTML I have this

<thead>
                        <tr style="display:none;">
                            <th></th>
                            <th></th>
                            <th></th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>             
                    </tbody>

Any ideas, options?

Answers

  • kiwiskiwis Posts: 15Questions: 10Answers: 0

    this is the error

    jquery.dataTables.js:3140 Uncaught (in promise) TypeError: Cannot set property '_DT_CellIndex' of undefined
    at _fnCreateTr (jquery.dataTables.js:3140)
    at _fnAddData (jquery.dataTables.js:2453)
    at HTMLTableRowElement.<anonymous> (jquery.dataTables.js:2481)
    at jquery.min.js:2
    at Function.map (jquery.min.js:2)
    at S.fn.init.map (jquery.min.js:2)
    at _fnAddTr (jquery.dataTables.js:2479)
    at _Api.<anonymous> (jquery.dataTables.js:8233)
    at _Api.iterator (jquery.dataTables.js:7068)
    at _Api.<anonymous> (jquery.dataTables.js:8231)

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    That error is normally generated when the column count in the header and body and data don't match - so that would be the place to start.

    If that doesn't solve it, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.