禁止在NG-格列过滤 [英] Disable filtering on a column in ng-grid
问题描述
我要NG-电网没有要根据特定列,但我不希望这些列仍然可排序的。
I want ng-grid not to search based on specific columns, but I do want those columns to still be sortable.
有没有办法做到这一点?
Is there a way to accomplish this?
推荐答案
对不起,我来晚了,全天都在开会: - \\得到了与从<一个我的答案示例的modfied版本运行href=\"http://stackoverflow.com/questions/25128833/nggrid-sort-entire-result-set/25133627#25133627\">here.
Sorry I'm late, meetings all day:-\ Got this running with a modfied version of my answer example from here.
这一种是基于从官方服务器双面分页例如这里。
我改变了code在 $ scope.getPagedDataAsync
来包括此过滤功能:
I changed the code in $scope.getPagedDataAsync
to include this filtering function:
if (searchText) {
var ft = searchText.toLowerCase();
data = $scope.longData.filter(function(item) {
var si=JSON.stringify(item.allowance).toLowerCase()+JSON.stringify(item.paid).toLowerCase();
if (si.indexOf(ft)!=-1){
return item;
};
});
这将产生从列数据字段串津贴
和付费
,ingores的名称
列,并且搜索的搜索文本的任何事件的生成的字符串。添加更多colums自己的喜好。
This will generate a string from the column data fields allowance
and paid
, ingores the name
column, and searches the generated string for any occurrence of the search text. Add more colums to your liking.
如果 SEARCHTEXT
终止该项目被返回到NG-电网字符串中随处可见。
If searchtext
is found anywhere in the string the item is returned to ng-grid.
这是不区分大小写,因此与toLowerCase()
部分。
This is case insensitive, hence the toLowerCase()
part.
这里查找工作 Plunker。
Find a working Plunker here.
这篇关于禁止在NG-格列过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!