This js-fiddle显示了一个带有null元素的示例。想要的行为应该是:
50,51,52,53,54,null(已经工作)
54,53,52,51,50,null(当前为null,54,53,52,51,50)
当数据按降序排序时,是否可以在orderBy
内使用sortable
? documentation似乎也没有详细说明sortable
接受什么
编辑:我为降序创建了一个自定义比较器,但它似乎并不影响数据。
var myApp = angular.module('myApp', ['ngTable'])
myApp.controller('MyCtrl', function($scope, NgTableParams) {
$scope.data = [{
name: "Test1",
age: 50
}, {
name: "Test2",
age: 51
}, {
name: "Test3",
age: 52
}, {
name: "Test4",
age: 53
}, {
name: "Test5",
age: 54
}, {
name: "Test6",
age: null
}];
$scope.tableParams = new NgTableParams({}, {
dataset: $scope.data
});
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-controller="MyCtrl">
<table ng-table="tableParams" class="table" show-filter="true">
<tr ng-repeat="user in $data">
<td title="'Name'" filter="{ name: 'text'}" sortable="'name'">
{{user.name}}</td>
<td title="'Age'" filter="{ age: 'number'}" sortable="'age'">
{{user.age}}</td>
</tr>
</table>
</div>