AngularJS UI电网得到尽管分页的过滤行 [英] AngularJS ui-grid get filtered rows in despite of pagination
本文介绍了AngularJS UI电网得到尽管分页的过滤行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有得到从UI的网格中的所有过滤的行即使我们使用分页任何解决方案?我知道,有一种方法
Is there any solution for get all filtered rows from ui-grid even we are using pagination? I know that there is a method
$scope.gridApi.core.getVisibleRows($scope.gridApi.grid);
返回页面上显示的所有列。但这种方法并不能帮助时过滤的数据更多的则是一个页面。
which returns all visible rows on page. But this method doesn't help when filtered data is more then one page.
推荐答案
我没有找到有关过滤数据的任何文件,所以我使用的方式是全手动。
I didn't find any Documentation about filter data so the way I used is fully manual.
让抢有源滤波器我们有:
Lets grab active filters we have:
function getGridUiFilters(){
var filters_ = _.filter($scope.gridApi.grid.columns, function(_column){
return _column.filter.term !== undefined && _column.filter.term !== null;
});
return filters_;
}
现在我们可以得到所有网格数据,并使用你定义的过滤器进行过滤 columnDefs
:
Now we can get all grid data and filter it by using filters you defined in columnDefs
:
function getFilteredDatagridIds(){
var gridFilters = getGridUiFilters();
var gridRows = $scope.gridApi.grid.rows;
var dataRows = _.map(gridRows, function(_row){
return _row.entity; // our object stored in row
});
var filteredDataRows = _.filter(dataRows, function(_row){
var isMatch = true;
angular.forEach(gridFilters, function (_filter) {
// call 'condition' method defined in 'columnDefs'
isMatch = isMatch &&
_filter.filter.condition(_filter.filter.term, _row[_filter.field] );
});
return isMatch;
});
return filteredDataRows;
}
在我的情况下 columnDefs
如下:
columnDefs: [
{displayName: 'Meeting', field: 'name_obj',
enableSorting: true,
enableColumnMenu: false,
cellTemplate: meetingNameCellTemplate,
headerCellTemplate: meetingNameHeaderCellTemplate,
filter: {
condition: function (searchTerm, cellValue) {
return cellValue.name.toLowerCase().indexOf(searchTerm.toLowerCase()) >= 0;
}
}
}, ....
所以我敢肯定,这个例子可以帮助你。
So I'm sure this example will help you
这篇关于AngularJS UI电网得到尽管分页的过滤行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文