ui-grid 添加搜索过滤

2020-03-10  本文已影响0人  我就是看看哦
onRegisterApi: function(gridApi){
   $scope.gridApi.grid.registerRowsProcessor( $scope.singleFilter, 200 );
}

html

<input type="text" placeholder="名称" ng-model="filterValue" ng-enter="filter()"/>
$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;
}
上一篇下一篇

猜你喜欢

热点阅读