美文网首页
ui-grid 添加搜索过滤

ui-grid 添加搜索过滤

作者: 我就是看看哦 | 来源:发表于2020-03-10 14:59 被阅读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;
}

相关文章

网友评论

      本文标题:ui-grid 添加搜索过滤

      本文链接:https://www.haomeiwen.com/subject/rybwdhtx.html