[英]Angularjs ui-grid filter cancel event
Hi I am using angular ui grid, I have filter and grouping in the grid I am expanding by default all rows using following 嗨,我使用的是角度ui网格,在网格中有过滤器和分组功能,默认情况下,使用以下命令扩展所有行
$scope.expandAll = function(){
$scope.gridApi.treeBase.expandAllRows();
};
$timeout(function() {
$scope.expandAll();
}, 500);
now if user filter on any column which is not available in data 现在,如果用户过滤了数据中不可用的任何列
And then remove or cancel, It does not expand automatically 然后删除或取消,它不会自动展开
It shows like above 如上图所示
I need all rows to expand automatically when user clear or cancel filter data 当用户清除或取消过滤器数据时,我需要所有行自动展开
I found there is an event filterChanged , but I don't know how to use that 我发现有一个事件filterChanged ,但是我不知道如何使用它
I am using following plunkr for testing 我正在使用以下plunkr进行测试
http://plnkr.co/edit/hhIW9R9aX1JlFe4nodJQ?p=preview http://plnkr.co/edit/hhIW9R9aX1JlFe4nodJQ?p=preview
Thanks 谢谢
Modify your onRegisterApi method to the following 将您的onRegisterApi方法修改为以下内容
onRegisterApi: function( gridApi ) {
$scope.gridApi = gridApi;
$scope.gridApi.core.on.filterChanged($scope, function() {
var grid = this.grid;
var isfilterclear = true;
angular.forEach(grid.columns, function( col ) {
if(col.filters[0].term){
isfilterclear = false;
}
});
if(isfilterclear) {
$timeout(function() {
$scope.expandAll();
},500);
}
});
}
see plunkr http://plnkr.co/edit/1FWDIe?p=preview 参见plunkr http://plnkr.co/edit/1FWDIe?p=preview
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.