jQuery DataTables - Child Rows and “Undefined is Not a Function”

前端 未结 1 1854
轮回少年
轮回少年 2021-01-03 07:29

I\'m working to add child rows to a data table and am getting a \"TypeError: undefined is not a function\" for a line of code that works perfectly on a different table and p

1条回答
  •  走了就别回头了
    2021-01-03 08:10

    I think you should replace

    var table = $('#users_table').dataTable({...

    by

    var table = $('#users_table').DataTable({

    The difference? Datable with a capital "D". Otherwise, you can't use the function table.row()

    From the manual (https://datatables.net/manual/api), you can see:

    It is important to note the difference between $( selector ).DataTable() and $( selector ).dataTable(). The former returns a DataTables API instance, while the latter returns a jQueryJS object. An api() method is added to the jQuery object so you can easily access the API, but the jQuery object can be useful for manipulating the table node, as you would with any other jQuery instance (such as using addClass(), etc.).

    0 讨论(0)
提交回复
热议问题