【问题标题】:Angular JS Smart Table Filtered collectionAngular JS 智能表过滤集合
【发布时间】:2015-03-22 12:48:28
【问题描述】:

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

该表与rowCollection 绑定。

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

我使用了搜索过滤器:

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

过滤结果后,我仍然可以看到rowCollection中的所有记录

【问题讨论】:

标签: angularjs smart-table


【解决方案1】:

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

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();
}

【讨论】:

    猜你喜欢
    • 2014-05-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-03
    • 1970-01-01
    相关资源
    最近更新 更多