1
我已經開始使用ngtables一定的難度。現在,分頁是正確的,但我不能做排序和過濾。沒有定義的初始排序順序是否有效任何建議? 感謝排序和過濾器不工作 - Ngtable
腳本
var app = angular.module('ruyapp', ['ngTable']);
app.controller('equipasCtrl', function ($scope, $filter, NgTableParams) {
var tamanho = $("#Tamanho").val();
$scope.init = function (equipasCT) {
$scope.equipas = equipasCT;
};
$scope.equipasTable = new NgTableParams({
page: 1,
sorting:{Nome: 'asc'},
count: $("#Npagina").val()
}, {
total: tamanho,
getData: function ($defer, params) {
$scope.data = params.sorting() ? $filter('orderBy')($scope.equipas, params.orderBy()) : $scope.equipas;
$scope.data = params.filter() ? $filter('filter')($scope.data, params.filter()) : $scope.data;
$scope.data = $scope.equipas.slice((params.page() - 1) * params.count(), params.page() * params.count());
$defer.resolve($scope.data);
}
});
});
查看
<div ng-app="ruyapp" ng-controller="equipasCtrl" ng-init="init(@Newtonsoft.Json.JsonConvert.SerializeObject(Model))">
<table class="table" ng-table="equipasTable" show-filter="true">
<tbody>
<tr ng-repeat="row in $data">
<td data-title="'Nome'" sortable="'Nome'" filter="{ 'Nome': 'text'}">
{{row.Nome}}
</td>
<td data-title="'Country'" sortable="'Country'" filter="{ 'Country': 'text'}">
{{row.Country}}
</td>
<td data-title="'Abreviatura'" sortable="'Abreviatura'" filter="{ 'Abreviatura': 'text'}">
{{row.Abreviatura}}
</td>
<td>
<a href="Equipas/Edit/{{row.EquipaID}}"> Editar</a> |
<a href="Equipas/Details/{{row.EquipaID}}"> Detalhes</a> |
<a href="Equipas/Delete/{{row.EquipaID}}"> Eliminar</a>
</td>
</tr>
</tbody>
</table>
</div>
ü可以創建一個小提琴? –