2016-05-17 65 views
0

我使用Inspinia角度主题的脚步来排序我得到的几个表。实际的插件是ziscloud角足迹(在这里找到https://github.com/ziscloud/angular-footable)。这张桌子有大约50个参赛作品,这个时候可能会获得更多的分数,所以在这个意义上分页是一条路。 我试图使用分页,但它不工作,再加上第一次加载所有的字段,然后它过滤前10项。Angular Footable(ziscloud)在过滤后只显示10个结果

<table class="table table-hover footable toggle-arrow-tiny" data-page-size="8"> 
    <thead> 
     <tr> 
      <th width="2%" data-sort-ignore="true"></th> 
      <th width="15%" data-sort-initial="true">Publish date</th> 
      <th width="15%">Start date</th> 
      <th width="20%">Name</th> 
      <th width="15%" data-sort-ignore="true">Total bookings</th> 
      <th width="23%" data-sort-ignore="true"></th> 
     </tr> 
    </thead> 
    <tbody> 
     <tr data-ng-repeat="item in vm.pastEducation"> 
      <td class="icon"> 
      <img ng-src="{{ vm.showActivityIcon(item.activity.descriptionText) }}" class="list-icon" alt="{{item.activity.descriptionText}}" title="{{item.activity.descriptionText}}"> 
      </td> 
      <td>{{ item.publishDate == '' ? "" : (item.publishDate | date : "yyyy-MM-dd hh:mm") }}</td> 
      <td>{{ item.startDate | date : "yyyy-MM-dd hh:mm" }}</td> 
      <td>{{ item.name }}</td> 
      <td></td> 
      <td class="align-right buttons"> 
      <button data-ng-click="vm.viewEducation(item.id)" class="btn btn-default btn-xs btn-outline"> 
       Show 
      </button> 
      </td> 
      </tr> 
    </tbody> 
    <tfoot> 
     <tr> 
      <td colspan="5"> 
       <ul class="pagination pull-right"></ul> 
      </td> 
     </tr> 
    </tfoot> 
</table> 

我已经在config.js文件中包含了正确的js,并且我没有在控制器中加载任何东西。

回答

0

首先分页工作从一开始就显示出来,但是只有当我点击表格标题之一,并且它还排序了所有值之后才显示出来。所以剩下要做的是在表格加载后找出如何触发过滤。 这里是我的控制器的初始化函数在那里做

(function initController() { 
    return educationService.listMin().then(function(data) { 
     vm.ongoingEducation = data.ongoingEducation; 
     vm.pastEducation = data.pastEducation; 
     $timeout(function() { $('table').trigger('footable_redraw'); }, 0); 
    }); 
    })(); 

此功能$超时(函数(){$( '表')触发器( 'footable_redraw');},0);在dom被加载后触发,从而成功触发过滤。由于我使用控制器,因此应该在控制器的开头声明$ timeout。