我使用列defs和showFilter创建了一个网格。一列使用cellTemplate根据该字段的值来操作输出。
当我尝试过滤数据时,我注意到过滤器会忽略该列。
我如何过滤网格中的所有列,包括引用cellTemplate的列?
这是我的网格:
$scope.gridStatusOptions = {
data: 'status',
showFilter: true,
columnDefs: [{ field: 'name', displayName: 'Name', cellFilter: '', cellTemplate: '' },
{ field: 'value', displayName: 'Value', cellFilter: '', cellTemplate: "<div class='ngCellText' ng-class='col.colIndex()'><span>{{formatState(row.entity)}}</span></div>"}]
};
此致
答案 0 :(得分:0)
ng-grid
中的过滤器处理基础数据,而不是呈现给浏览器DOM
的内容。
必须如此,因为如果您的数据来自服务器,它也必须在服务器端进行预过滤,分页和排序。
如果您没有正确格式的(待过滤)字段,请对数据进行转换并添加预先格式化的字段。
看看我几天前给出的answer here。
顺便说一句:如果您想正确格式化问题中的代码,只需选择它并点击CTRL-K
即可。使其更具可读性。