过滤在ui-grid中不起作用,但是当我从html部分删除ui-grid-selection指令时,过滤效果很好!!! 注意:我稍后通过服务调用动态填充gridOptions的columnDefs。
.js代码:
$scope.gridOptions = {
,enableRowSelection: true
, enableRowHeaderSelection: true
, multiSelect: false
, treeRowHeaderAlwaysVisible: false
, useExternalFiltering: true
, onRegisterApi: function (gridApi) {
self.gridApi = gridApi;
gridApi.core.on.filterChanged($scope, function () {
if (!usePagination)
return;
var grid = this.grid;
var gridfilter = [];
angular.forEach(grid.columns, function (col, index) {
if (col.filters[0].term)
gridfilter.push(
{
FieldName: col.name,
MatchType: 6,
Value1: col.filters[0].term
}
);
});
self.searchOption.filters = [{ filter: gridfilter }];
self.reload();
});
}
.html代码:
<div ui-grid="gridOptions" dir="rtl" style="height: 600px; width: 100%"
ui-grid-selection></div>
答案 0 :(得分:0)
我在gridOption中启动了columnDefs并解决了问题:
$scope.gridOptions = {
columnDefs:[{}]
,enableRowSelection: true
....
}