我试图在设计中使用dirPagination,但它不起作用-在我的代码中,我动态地传递rowspan,将每个月的一天分组在一行中,以获得最终结果:
https://cloud.githubusercontent.com/assets/7356190/8421324/242770f8-1ecd-11e5-8f84-fb2f47bf79d1.png
HTML代码:
<div class="panel panel-default panel-hovered panel-stacked mb20">
<div class="panel-heading" style="font-size:15px;">عرض العملاء الغير جاهزين</div>
<div class="panel-body" dir="rtl" ng-app="jqanim" ng-controller="InvoiceController">
<input type="text"
class="form-control input-sm ng-pristine ng-valid ng-touched"
placeholder="اكتب جزء من الاسم او المدينة او النوع او التاريخ ..."
tabindex="0"
aria-invalid="false"
ng-model="searchText">
<br />
<br />
<table class="table table-bordered">
<thead>
<tr class="text-center">
<td>الشهر</td>
<td>العميل</td>
<td>المدينة</td>
<td>النوع</td>
<td>التاريخ</td>
</tr>
</thead>
<tbody dir-paginate="customer in customersByMonth | itemsPerPage: 2">
<tr ng-repeat='cust in customer | filter:searchText'>
<td ng-if="$first" rowspan="{{customer.length}}" class="text-center">
{{cust.MirageDate | date: 'yyyy-MM'}}
</td>
<td>{{cust.CustomerName}}</td>
<td class="text-center">{{cust.City.CityName}}</td>
<td class="text-center">{{cust.Type.TypeName}}</td>
<td class="text-center">{{cust.MirageDate | date: 'yyyy-MM-dd'}}</td>
</tr>
</tbody>
</table>
<div class="text-center">
<dir-pagination-controls boundary-links="true" template-url="/dirPagination.tpl.html"></dir-pagination-controls>
</div>
</div>
JS代码:
<script>
var app = angular.module('jqanim', []);
app.controller('InvoiceController', [
'$scope', '$http', function ($scope, $http) {
$http.get("/api/NoReady")
.success(function (data) {
var dataByMonth = {};
data.forEach(itemToMonth);
$scope.customersByMonth = dataByMonth;
function itemToMonth(item) {
item.MirageDate = new Date(item.MirageDate)
var month = item.MirageDate.getMonth();
var year = item.MirageDate.getFullYear();
dataByMonth[year + '-' + month] = dataByMonth[year + '-' + month] || [];
dataByMonth[year + '-' + month].push(item);
}
});
}
]);
plnkr上的示例项目:http://plnkr.co/edit/hr9zj6WMW0G6oRWOxC63?p=preview
因为你可以看到什么都没有发生-我只需要在每页中显示2个正文
标准表应该有一个<tbody>
标记。
尝试在<tr>
标记上使用dir-paginat
,然后使用ng-init
创建一个要动态显示的值。