使用Scroller的数据表不起作用

编程入门 行业动态 更新时间:2024-10-26 16:21:26
本文介绍了使用Scroller的数据表不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

使用DataTable的最新版本(1.10.9)和滚动器小部件(1.3.0),我无法使它与以下简单代码段一起工作:

Using the last version of DataTable (1.10.9) and the scroller widget (1.3.0), I can't make it work with this simple piece of code:

var data = [{'a': 'a', 'b': 'b'}, {'a': 'c', 'b': 'd'}]; var columns = [{'title': 'a', 'data': 'a'}, {'title': 'b', 'data': 'b'}]; $("#mytable").DataTable({ "processing" : true, "filter": false, "orderClasses": false, "ordering": false, data: data, deferRender: false, scrollY: 400, scrollCollapse: true, scroller: { loadingIndicator: true }, dom: "rtiS", columns: columns, });

结果,我有一个空表,并显示消息显示NaN到-Infinity of 2个条目".在没有滚动器小部件的情况下,它工作正常(但我需要它).

As a result, I have an empty table with message "Showing NaN to -Infinity of 2 entries". WIthout the scroller widget, it is working fine (but I need it).

我想念什么?

推荐答案

我找到了原因=>我从ajax响应中应用了DataTable,该响应也将表插入到DOM中.

I found the reason => I apply DataTable from an ajax response that also insert the table into the DOM.

在$(document).ready中调用JS会导致该错误.

Calling the JS in a $(document).ready causes the bug.

使用setTimeout可以避免错误...

Using a setTimeout avoids the bug ...

更多推荐

使用Scroller的数据表不起作用

本文发布于:2023-10-27 02:48:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1532079.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据表   不起作用   Scroller

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!