定制" cellfilter"在角JS [英] Custom "cellfilter" in Angular js
本文介绍了定制" cellfilter"在角JS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在角JS的NG-电网工作。
我有这行code的定义添加过滤器的类型。
I am working with the ng-grid in Angular js. I have this line of code which defines the type of filter added.
columnDefs: [{field:'date', displayName:'Birth Date', cellFilter:'date:\"dd MMM yyyy\"'},
{field:'pre', displayName:'Prev', cellFilter:'number'},
{field:'fct', displayName:'Fct', cellFilter:'number'},
{field:'act', displayName:'Act', cellFilter:'number'}
{field:'imp', displayName:'Important', cellFilter:'number'}]
};
重要列具有值H,L和M。通过正常(按字母顺序)排序,我可以实现一种H-L-M的,但有一种方法来定义一个过滤器,排序为H-M-L。
任何帮助是AP preciated!感谢:)
Any help is appreciated!! Thanks :)
推荐答案
使用自定义排序功能:
var result = 1;
var test="HML";
function impSortFn(a, b) {
a=test.indexOf(a);
b=test.indexOf(b);
if (a == b) return 0;
if (a < b) return -1;
return result;
}
$scope.gridOptions = {
data: 'myData',
columnDefs: [{
field: 'name',
displayName: 'Name'
}, {
field: 'age',
displayName: 'Age'
}, {
field: 'imp',
displayName: 'Important',
sortFn: impSortFn
}]
这篇关于定制&QUOT; cellfilter&QUOT;在角JS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文