ui-grid 添加搜索过滤

onRegisterApi: function(gridApi){
   $scope.gridApi.grid.registerRowsProcessor( $scope.singleFilter, 200 );
}

html


$scope.filter = function () {
    $scope.gridApi.grid.refresh();
};
$scope.filterValue = ""
$scope.singleFilter = function (renderableRows) {
    var matcher = new RegExp($scope.filterValue, 'i');
    renderableRows.forEach(function (row) {
        var match = false;
        ['name'].forEach(function (field) {
            if (row.entity[field].match(matcher)) {
                match = true;
            }
        });
        if (!match) {
            row.visible = false;
        }
    });
    return renderableRows;
}

你可能感兴趣的:(ui-grid 添加搜索过滤)