我正在尝试使用此处描述的数据表实现无限滚动:并遇到一些问题
这是我到目前为止所做的:
//JS
@.load_datatables = (container, options) ->
container = "" if not container?
datatable_options = {
"destroy": true
"serverSide": true
"processing": true
"lengthMenu": [40]
"scroller": true
"scrollY": "200",
"scrollCollapse": true
"dom": "<'row'<'col-xs-12 filter'f>r>t<'row'<'col-xs-12'p>>"
}
$(this).dataTable(datatable_options).removeClass('hidden')
并且我dataTables/extras/dataTables.scroller
的两个基本资产文件(脚本和 CSS)都需要。
但是,我面临以下问题:
一:一个全新的表格正在我的.dataTables_scrollBody
二:表格在滚动时未获取更多数据(无限滚动无响应)
三:我有时会报错:Uncaught TypeError: Cannot read property 'style' of undefined
.
我的html(或erb)如下:
<div class="row">
<div class="col-md-12">
<table id="loans" class="datatable hidden click-through styled" data-search-label="Loans search" data-source="<%= data_path(:format => 'json') %>" >
<thead>
<tr>
<th>#</th>
<th>#</th>
<th>#</th>
...
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
我做错了什么?我的模板设置好了吗?
非常感谢这里的任何帮助!