使用两者时,ui-grid过滤和选择不起作用

时间:2017-07-27 12:50:37

标签: angular-ui-grid

当选择打开时,

过滤在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>

1 个答案:

答案 0 :(得分:0)

我在gridOption中启动了columnDefs并解决了问题:

$scope.gridOptions = {
         columnDefs:[{}]
         ,enableRowSelection: true
         ....
}