Datatable with Scroller not working

☆樱花仙子☆ 提交于 2019-12-13 05:23:49

问题


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,
                    });

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).

What did I miss?


回答1:


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

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

Using a setTimeout avoids the bug ...



来源:https://stackoverflow.com/questions/32652947/datatable-with-scroller-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!