【发布时间】:2015-02-27 14:11:44
【问题描述】:
处理包含 1000 多条记录的 ngTable。 一切正常,但我面临的唯一问题是过滤器。 它只过滤活动页面中的文本。 假设我在第 3 页,如果我使用文本框搜索/过滤某些内容,则它必须来自第 3 页,否则它不会显示任何内容..
我的代码如下:
$scope.$watch("filter.$", function () {
$scope.tableParams.reload();});
$scope.tableParams = new ngTableParams({
page: 1, // show first page
count: 10, // count per page
sorting: {
schoolName: 'asc' // initial sorting
}
},
{
total: $scope.schoolInfo.length, // length of data
getData: function ($defer, params) {
var filteredData = {};
//reason I am doing this is to get the data always filtered, no matter what
var orderedData = $filter('orderBy')($scope.schoolName, params.orderBy());
params.total(orderedData); // set total for recalc pagination
$defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
},$scope:$scope
});
排序工作完美,但仅用于搜索
搜索:<input type="text" ng-model="search.schoolName">
我也试过 ng-model="search"
<tr ng-repeat="mydata in $data | filter:search">
我也试过搜索:严格
如果有人可以帮助我,似乎没有任何帮助?
提前致谢
【问题讨论】:
标签: javascript angularjs angularjs-ng-repeat angular-ui ngtable