根据 angular-dataTables 中的要求排序不工作
sorting not working as per requirement in angular-dataTables
我的项目有问题。我正在使用 angular 数据表。排序时,如果我有一列的数据为 1.4
、1.5
、10
、2.4
我需要 return 作为 1.4
、1.5
、2.4
、10
。但我得到的是 1.4
、1.5
、10
、2.4
。我想它只考虑第一个字符。
有什么解决办法吗?下面是代码片段。
$scope.dtOptions = { paging: false, searching: false };
$scope.dtColumnDefs = [
];
我不确定我必须在列 defs 中写什么来排序
我猜想列中某处的值会转换为非法数字,从而将自动检测到的类型转换为 alpha 排序。通过设置 type
强制列的排序类型 - num
用于数字:
$scope.dtColumns = DTColumnBuilder.newColumn(0)
.withOption('type', 'num') //<---
.withTitle('#')
演示 -> http://plnkr.co/edit/teKt4xgTWD98IfBc2dNb?p=preview
尝试评论 .withOption('type', 'num')
..
如果您想了解语法,它与
相同
$scope.dtColumnDefs = [
{ targets: 0, type: 'num', title: '#' }
];
我的项目有问题。我正在使用 angular 数据表。排序时,如果我有一列的数据为 1.4
、1.5
、10
、2.4
我需要 return 作为 1.4
、1.5
、2.4
、10
。但我得到的是 1.4
、1.5
、10
、2.4
。我想它只考虑第一个字符。
有什么解决办法吗?下面是代码片段。
$scope.dtOptions = { paging: false, searching: false };
$scope.dtColumnDefs = [
];
我不确定我必须在列 defs 中写什么来排序
我猜想列中某处的值会转换为非法数字,从而将自动检测到的类型转换为 alpha 排序。通过设置 type
强制列的排序类型 - num
用于数字:
$scope.dtColumns = DTColumnBuilder.newColumn(0)
.withOption('type', 'num') //<---
.withTitle('#')
演示 -> http://plnkr.co/edit/teKt4xgTWD98IfBc2dNb?p=preview
尝试评论 .withOption('type', 'num')
..
如果您想了解语法,它与
相同$scope.dtColumnDefs = [
{ targets: 0, type: 'num', title: '#' }
];