AngularJs对所有页面中的所有记录进行排序
AngularJs Sorting all records across all pages
嘿,当我使用排序键和函数时,每个人都在试图对我的所有记录进行排序。我只在当前页面上进行排序,但我没有得到它为什么它只在当前页上进行排序?以下是我的代码:
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th ng-click="sort('cin')">Cin <span
class="glyphicon sort-icon" ng-show="sortKey=='cin'"
ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span>
</th>
<th ng-click="sort('nom')">Nom <span
class="glyphicon sort-icon" ng-show="sortKey=='nom'"
ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span>
</th>
<th ng-click="sort('prenom')">Prenom <span
class="glyphicon sort-icon" ng-show="sortKey=='prenom'"
ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span>
</th>
<th ng-click="sort('email')">Email <span
class="glyphicon sort-icon" ng-show="sortKey=='email'"
ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span>
</th>
<th ng-click="sort('adresse')">Adresse <span
class="glyphicon sort-icon" ng-show="sortKey=='adresse'"
ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span>
</th>
<th>index</th>
<th ng-click="sort('role_name')">Roles <span
class="glyphicon sort-icon" ng-show="sortKey=='adresse'"
ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span>
</th>
</tr>
</thead>
<tbody>
<tr
dir-paginate="user in users|orderBy:sortKey:reverse|filter:search|itemsPerPage:5">
<td>{{user.cin}}</td>
<td>{{user.nom}}</td>
<td>{{user.prenom}}</td>
<td>{{user.email}}</td>
<td>{{user.adresse}}</td>
<td>{{$index}}</td>
<td><table>
<tr ng-repeat=" role in user.roles">
<td>{{role.role_name}}</td>
</tr>
</table></td>
<td>
<button ng-click="edit(user)" class="btn btn-warning btnt"
data-toggle="modal" data-target="#myModal">
<i class="glyphicon glyphicon-pencil"></i>
</button>
</td>
<td><button ng-click="supp(user.cin)"
class="btn btn-danger btnt">
<i class="glyphicon glyphicon-remove"></i>
</button></td>
</tr>
</tbody>
</table>
这是我的js代码:
$scope.sort = function(keyname){
$scope.sortKey = keyname; // set the sortKey to the param passed
console.log("keyname="+$scope.keyname);
$scope.reverse = !$scope.reverse; // if true make it false and
// vice versa
}
ᐧ感谢任何帮助
您可以尝试的一件事是在控制器本身中对结果进行排序
$filter('orderBy')($scope.users, 'cin');
其中$scope.users是您要重复的内容,cin是您的排序标准。
希望得到帮助!
相关文章:
- 使用Dnamics CRM 2011中的JavaScript读取子网格的所有记录,而不考虑活动页面
- JavaScript数组排序(函数)用于对表行进行排序,而不是排序
- 使用promise和mongoose对文档进行排序
- Selectize.js:如何对整数值的选项进行排序
- AngularJs对所有页面中的所有记录进行排序
- 表过滤,排序,在html中使用jquery/javascript/css进行区分记录
- 获取按月排序的Spotify用户收听历史记录
- NodeJS时间戳:比较时间并显示记录排序升序
- Angularjs;在所有记录中排序,而不仅仅是在当前页面中
- 如何在ExtJS存储中获取记录的预排序索引
- JQGrid在列排序时丢失记录
- 不要在Sails.js的collection属性中按id记录排序
- Firebase对特定记录的索引进行排序和检索
- 按升序对记录数组进行排序
- 可排序的Angular数据表——可排序的表在第一次加载时呈现良好,但在后续过滤器中不产生记录
- 未捕获的JS错误在Extbase扩展排序记录在列表视图
- Extjs 4.2可排序的网格与固定位置的一个记录
- 在Cloudkit.JS中按时间戳对记录进行排序
- jqgrid:动态添加记录后排序不起作用
- 在 Angular js 中按 Id 降序对记录进行排序时出错,并带有 orderby 子句