2

Where is the filtered collection after filtered value in smart table.

the table is bound with rowCollection.

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

and i have used a search filter:

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

after the result are filtered i still see all records in rowCollection

Mosh Feu
  • 28,354
  • 16
  • 88
  • 135
Usama Khalil
  • 436
  • 1
  • 4
  • 14

1 Answers1

7

You can create a directive to access the get the filtered Collection. For example:

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();
}
Luke Hutton
  • 10,612
  • 6
  • 33
  • 58
yilik01
  • 138
  • 8