简体   繁体   English

为什么Footable分页无法正确呈现?

[英]Why is Footable pagination not rendering properly?

I'm trying to implement Footable, a JQuery plugin used to make tables responsive. 我正在尝试实现Footable,一个用于使表响应的JQuery插件。 There is an add-on for Footable to add pagination. Footable有一个附加组件可以添加分页。 [Demo] [演示]

And ( http://fooplugins.com/footable/demos/paging.htm ) for using the pagination add-on. 和( http://fooplugins.com/footable/demos/paging.htm )使用分页插件。 I tried following this demo but my pagination came up as a vertical un-ordered list. 我尝试过这个演示,但我的分页是一个垂直的无序列表。 The buttons are functional but unsightly. 按钮功能但难看。 Here is a link images which i can not post here because my repuation is not high enough. 是一个链接图像,我不能在这里发布,因为我的回复不够高。

Here is my code for the table: 这是我的表代码:

<table class="table table-hover" ng-show='form.length>0' data-page-navigation=".pagination">
    <thead>
        <th ng-repeat="(key, formAttr) in form | orderBy:'attributes.order'" >{{formAttr.attributes.name}}<br/>({{formAttr.type}})</th>
        <th>Submission Time</th>
    </thead>
    <tbody>
        <tr ng-repeat="(key, response) in formResponses">
            <td ng-repeat="(key, formAttr) in form | orderBy:'attributes.order'">{{$parent.response.results[formAttr.att_id]}}</td>
            <td>{{response.submission_time}}</td>
        </tr>
    </tbody>
    <tfoot class="">
        <tr>
            <td colspan="5">
                <div class="pagination pagination-centered"></div>
            </td>
        </tr>
    </tfoot>
</table>

Your footer should look something like this: 你的页脚应该是这样的:

<tfoot class="hide-if-no-paging">
  <tr>
    <td colspan="5" class="text-center">
        <ul class="pagination">
        </ul>
    </td>
  </tr>
</tfoot>

You can tell, that's different that what it says in the demo. 你可以说,它与演示中的内容有所不同。 This link showed me the difference https://github.com/bradvin/FooTable/issues/136 . 这个链接向我展示了差异https://github.com/bradvin/FooTable/issues/136

Here's a plunk to demonstrate the issue: http://plnkr.co/edit/8Yyk8NN8rsqdXtrvJDOM 这是一个证明问题的插图: http//plnkr.co/edit/8Yyk8NN8rsqdXtrvJDOM

You need to add both attribute for pagination: 您需要为分页添加两个属性:

data-page-navigation=".pagination" data-page-size="2" into table tag data-page-navigation=".pagination" data-page-size="2"进入表格标签

(If not placing the pagination in the table footer) Don't use a CSS class for table-to-pagination relationships. (如果没有将分页放在表格页脚中)不要将CSS类用于表格到分页关系。 Use CSS ID instead. 请改用CSS ID。

Consider the following... 考虑以下...

BAD - Example using CSS class to relate pagination object to table: BAD - 使用CSS类将分页对象与表关联的示例:

<table id="table1" class="footable" data-page-navigation=".pagination" data-page-size="10">
    <thead>
        <th>Some Title</th>
        <th>Some other Title</th>
    </thead>
    <tbody>
        <tr>
            <td>some data</td>
            <td>some more data</td>
        </tr>
    </tbody>
</table>
<div class="pagination hide-if-no-paging"></div>

<table id="table2" class="footable" data-page-navigation=".pagination" data-page-size="10">
    <thead>
        <th>Some Title</th>
        <th>Some other Title</th>
    </thead>
    <tbody>
        <tr>
            <td>some data</td>
            <td>some more data</td>
        </tr>
    </tbody>
</table>
<div class="pagination hide-if-no-paging"></div>

The footable javascript code will see two pagination objects. footable javascript代码将看到两个分页对象。 Which will be used by table1 and which will be used by table2 is not deterministic. table1将使用哪个,table2将使用哪个不确定。 This throws the footable javascript into a tizzy. 这使得足够的javascript陷入了眩晕。

Rather than use CSS classes, be more specific by using a CSS ID instead. 而不是使用CSS类,而是使用CSS ID更具体。

GOOD - Example using CSS ID to relate pagination object to table: GOOD - 使用CSS ID将分页对象与表关联的示例:

<table id="table1" class="footable" data-page-navigation="#pagination1" data-page-size="10">
    <thead>
        <th>Some Title</th>
        <th>Some other Title</th>
    </thead>
    <tbody>
        <tr>
            <td>some data</td>
            <td>some more data</td>
        </tr>
    </tbody>
</table>
<div id="pagination1" class="pagination hide-if-no-paging"></div>

<table id="table2" class="footable" data-page-navigation="#pagination2" data-page-size="10">
    <thead>
        <th>Some Title</th>
        <th>Some other Title</th>
    </thead>
    <tbody>
        <tr>
            <td>some data</td>
            <td>some more data</td>
        </tr>
    </tbody>
</table>
<div id="pagination2" class="pagination hide-if-no-paging"></div>

Javascript Example: Javascript示例:

$(document).ready(function () {
    $(".footable").footable();
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM