1

I am trying to use footable in my rails application.But I am unable to implement pagination with my dynamic table data.

Here is my code

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

But It shows only 10 records though it contains upto 45 in table(shows maximum of 10 records even changing data-page-size).

Help me If anyone finds this issue,Thaks In advance.

vjnan369
  • 833
  • 16
  • 42

1 Answers1

0

Not sure if you are still having this issue but I've stumbled upon this question so I figured I'd answer it.

The reason this is occurring is because you're calling Footable's Paging Component on records that you have already paginated via a Rails gem, indicated by your use of

...
<ul class="pagination pull-right">
  <%=paginate @organizations%>
</ul>
...

So Footable is only being served 10 records by your Rails app and then trying to paginate those. Essentially you're "double paginating" one set of data.

In Footable V3 the syntax is now:

Calling it via HTML Data Attributes

<table class="footable table table-stripped" ... data-paging="true" data-paging-size="15" ... >

Calling it via JS

$('.footable').footable({
                "paging": {
                    "enabled": true,
                    "limit": 10
                  }
               });

Refer to Footable Paging Docs for more info.

So essentially, choose either Rails Paginate or Footable Paging but not both. Hope this helps.

cdouble.bhuck
  • 507
  • 1
  • 5
  • 19