【问题标题】:JQuery DataTables Plugin : TypeError: e[j] is undefinedJQuery DataTables 插件:TypeError:e[j] 未定义
【发布时间】:2014-08-25 23:25:22
【问题描述】:

我不明白为什么 DataTables 在 FF 中抛出这个错误:TypeError: e[j] is undefined

在 IE 中报告为:无法获取未定义或空引用的属性 'aDataSort'

这里是代码

HTML

<table id="fp_promotion_history">
<thead>
    <tr>
        <th>AuditID</th>
        <th>Action</th>
        <th>Description</th>
        <th>User Name</th>
        <th>Audit Date</th>
    </tr>
</thead>
<tbody>
    <tmpl_loop name='fp_history'>
        <tr id="AuditID_<tmpl_var name='AuditID'>">
            <td data-AuditID="<tmpl_var name='AuditID'>"><tmpl_var name='AuditID'></td>  
            <td data-Action="<tmpl_var name='Action'>"><tmpl_var name='Action'></td>
            <td data-Audit_Desc="<tmpl_var name='Audit_Desc'>"><tmpl_var name='Audit_Desc'></td>
            <td data-User_Name="<tmpl_var name='User_Name'>"><tmpl_var name='User_Name'></td>               
            <td data-Audit_Date="<tmpl_var name='Audit_Date'>"><tmpl_var name='Audit_Date'></td>
        </tr>
    </tmpl_loop>
</tbody>
</table>

jQuery

        showDialog({content:data,title:'Financial Promotion Audit Trail History (FPID : ' + $('#fp_promotions_table tr.selected').attr('id') + ')'});                                            

        // turn into a datatable
        $('#fp_promotion_history').dataTable({        
                "sDom": 'R<"H"fr>t<"F"ip>',            
                "bJQueryUI": true,
                "sPaginationType": "full_numbers",
                "iDisplayLength": 25,
                "order": [[ 5, "desc" ]]
        });

我不明白的是我已经在页面上有一个工作正常的数据表。

我进行了 AJAX 调用,使用 JQuery UI 对话框显示结果(表格),但是当我尝试将其转换为 DataTable 时,它​​只是错误?

文档暗示多个表是可以的:http://legacy.datatables.net/release-datatables/examples/basic_init/multiple_tables.html

那我做错了什么?

谢谢, 1DMF

【问题讨论】:

    标签: jquery ajax datatables jquery-datatables


    【解决方案1】:

    我相信是因为订单参数

    "order": [[ 5, "desc" ]] 
    

    似乎列排序是基于零的,这在文档中并不清楚:https://datatables.net/reference/api/order()

    它一直将第 1 列提到为 [1] 而不是 [0]。

    【讨论】:

    • 令人惊讶的是,他们在 2017 年没有对此进行修改,因此引发了更清晰的错误。
    【解决方案2】:

    这实际上是我最近偶然发现的一个非常常见的错误。 这可能是由于设置中的索引错误,例如:

    • aaSorting
    • 订购
    • columnDefs.targets
    • columnDefs.orderData 等

    如果您的列是 n,您可以使用 0 到 n-1 之间的索引。在设置中使用这些索引以外的索引可能会导致此错误。 希望能帮助到你。

    【讨论】:

      【解决方案3】:

      这样的错误 f[0] is undefined 发生在我身上 是因为dom不见了

      't' 丢失(表格)

      dom='tlip'

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2010-12-13
        • 1970-01-01
        • 2017-10-22
        • 2014-11-14
        • 2011-01-09
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多