2

智能表中过滤值后的过滤集合在哪里。

该表与 绑定rowCollection

<table st-safe-src="rowCollection" st-table="displayed" class="table table-bordered">

我使用了搜索过滤器:

<input type="text" id="regionFilter" st-search="region" />

结果被过滤后,我仍然看到所有记录rowCollection

4

1 回答 1

7

您可以创建一个指令来访问获取过滤后的集合。例如:

HTML:

<table 
    st-table="displayedCollection" 
    st-safe-src="rowCollection" 
    on-filter="onFilter">

Javascript:

//
// Create a directive
//
angular.module("smart-table").directive('onFilter', function () {
    return {
        require: '^stTable',
        scope: {
            onFilter: '='
        },
        link: function (scope, element, attr, ctrl) {

            scope.$watch(function () {
                return ctrl.tableState().search;
            }, function (newValue, oldValue) {
                scope.onFilter(ctrl);
            }, true);
        }
    };
});

//
// In your controller
//
$scope.onFilter = function (stCtrl) {
    var filtered = stCtrl.getFilteredCollection();
}
于 2015-05-18T02:02:41.970 回答