Datatables TypeError: c is undefined

后端 未结 9 1373
[愿得一人]
[愿得一人] 2020-12-03 09:20

I try to use jQuery DataTables but I get the error

TypeError: c is undefined

I don\'t know what is wrong with my code as I can s

相关标签:
9条回答
  • 2020-12-03 10:18

    Check whether you have added

    <thead></thead>
    
    <tbody></tbody>
    

    I've resolved this problem by adding those.

    So basically the structure must be like:

    <table>
     <thead>
      <tr>
       <th></th>
       <th></th>
      </tr>
     </thead>
     <tbody>
      <tr>
       <td></td>
       <td></td>
      </tr>
     </tbody>
    </table>
    
    0 讨论(0)
  • 2020-12-03 10:24

    dataSrc is a special dataTables ajax option, that should be included inside the ajax object :

    "ajax": {
        "dataSrc": "Data", //<--- place dataSrc here instead
        "type": "POST",
        ...
    }
    

    You have placed it outside ajax, and by that dataTables have no idea what source to use (besides blindly trying the ajax response) or where LOGIN belongs.

    0 讨论(0)
  • 2020-12-03 10:24

    Sometime, This type issue arrives by fixing mismatched / unequal columns with HTML and datatables columns.

    "columns": [
            null,
            null,
            null,
            {"orderable": false, "width":"2%"},
        ],
    

    Above javascript defined 4 columns and HTML having 5 columns

    <tr>
       <td>A</td>
       <td>B</td>
       <td>C</td>
       <td>D</td>
       <td>E</td>
    </tr>
    

    Hence you will have to fix / equal both side HTMl and Datatable configuration.

    "columns": [
            null,
            null,
            null,
            null, //Added New
            {"orderable": false, "width":"2%"},
        ],
    
    0 讨论(0)
提交回复
热议问题