Uncaught TypeError: Cannot read property 'length' of null

Uncaught TypeError: Cannot read property 'length' of null

pukiwawapukiwawa Posts: 2Questions: 1Answers: 0
edited August 2021 in General

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Uncaught TypeError: Cannot read property 'length' of null
Description of problem:
Why i am having this error on all my datable?

below is my code in my html:

<table id="myTable" class="display" style="width:100%">
                <thead align="center">
                    {% for col in df_weight.columns %}
                        {% if forloop.counter == 1 %}
                            <th>{{col}}</th>
                        {% else %}
                            <th>{{col}}月</th>
                        {% endif %}
                    {% endfor %}
                </thead>
                <tbody>
                    {% for row in df_weight.values %}
                    <tr>
                    {% for ro in row %}
                        {% if forloop.counter == 1 %}
                            <td>{{ro}}</td>
                        {% else %}
                            <td align="right">{{ro|floatformat:"2"}}</td>
                        {% endif %}
                    {% endfor %}
                    </tr>
                    {% endfor %}
              </tbody>
</table>

```js
<script>
$(document).ready(function() {
    $('#myTable').DataTable( {
        dom: 'lftBip',
        buttons:[{
            extend: 'excel',
            text:'下载Excel格式',
            extension: '.xlsx',
            filename: 'download',
        }],
        "language": {
            "url": "{% static 'i18n/Chinese.json' %}"
        }
    } );
} );
</script>

Answers

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    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

  • pukiwawapukiwawa Posts: 2Questions: 1Answers: 0

    Dear Collin,

    Many thanks for your reply. I have found the cause, it has nothing to do with data tables.

    Cheers~

    Pang

Sign In or Register to comment.