我正在尝试在Rails应用程序中使用footable,但是无法使用动态表数据实现分页。
这是我的代码
<table class="footable table table-stripped" data-page-size="10" data-filter=#filter>
<thead>
<tr>
<th>Organization Name</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<%@organizations.each do |org|%>
<tr class="gradeX">
<td><%=org.name%></td>
<td><%=org.type%></td>
</tr>
<%end%>
</tbody>
<tfoot>
<tr>
<td colspan="5">
<ul class="pagination pull-right">
<%=paginate @organizations%>
</ul>
</td>
</tr>
</tfoot>
</table>
<script type="text/javascript">
$(function() {
alert(); //testing
$('.footable').footable();
});
</script>
但是,尽管表中最多包含45条记录,但它仅显示10条记录(即使更改数据页大小,最多显示10条记录)。
帮助我,如果有人发现此问题,请提前致意。
最佳答案
不知道您是否仍然遇到这个问题,但是我偶然发现了这个问题,所以我想我会回答。
发生这种情况的原因是,您在已经通过Rails gem分页的记录上调用了Footable的Paging Component
,用
...
<ul class="pagination pull-right">
<%=paginate @organizations%>
</ul>
...
因此,您的Rails应用仅向Footable提供10条记录,然后尝试对这些记录进行分页。本质上,您是在“双重分页”一组数据。
在
Footable V3
中,语法现在为:通过HTML数据属性调用
<table class="footable table table-stripped" ... data-paging="true" data-paging-size="15" ... >
通过JS调用
$('.footable').footable({
"paging": {
"enabled": true,
"limit": 10
}
});
有关更多信息,请参考Footable Paging Docs。
因此,从本质上讲,选择“ Rails分页”或“步行式分页”,但不能两者都选。希望这可以帮助。