【问题标题】:Uncaught TypeError: Object [object Object] has no method 'fnStandingRedraw'未捕获的类型错误:对象 [object Object] 没有方法“fnStandingRedraw”
【发布时间】:2013-10-23 20:27:19
【问题描述】:

我有一个只有几行的数据表,我想在表中添加新行:

  var oTable = $('#StudentsTable').dataTable();
  Table2.fnStandingRedraw();

当我初始化我添加的数据表时:

            "bProcessing": true,
            "bServerSide": true,
            "bDestroy": true,
            "fnFilter": true,
            'bLengthChange': true,
            'bPaginate': true,
            'bStandingRedraw': true,

ajax 提交后,我想重排表格:

submitHandler: function(form) {
            var $modal = $('#ajax-modal');
            $modal.modal('loading');
            $(form).ajaxSubmit({
                dataType: 'json',
                success: function(result) {
                    if (result.Success) {
                        if (result.Data.Action == "add") {
                            var oTable2 = $('#StudentsTable').dataTable();
/*=>here is Call redraw */  oTable2.fnStandingRedraw();
                        }

这里给我错误: Uncaught TypeError: Object [object Object] has no method 'fnStandingRedraw'

有什么建议吗?

【问题讨论】:

  • 不是默认的 API 方法。此参考页面是使用数据表时的救星:datatables.net/ref

标签: javascript jquery jquery-datatables redraw


【解决方案1】:

您忘记包含fnStandingRedraw 插件。确保将其添加到数据表的脚本文件之后。

将 sn-p 复制并粘贴到脚本顶部也可以,但将其放在单独的文件中可能会被证明更有条理且可重复使用。或者您也可以在未压缩的 Datatables 源文件的末尾连接此 sn-p 并完全缩小它,因此在包含 Datatables 脚本时它始终可用。

【讨论】:

    猜你喜欢
    • 2014-01-08
    • 2013-04-19
    • 2012-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多