Вопрос

I have two ng-grids in the same view/partial and need to identify on which ng-grid was the sort event fired. How do I do that? I am using the ngGridEventSorted event.

Это было полезно?

Решение

You can access the scope on which the event was fired with event.targetScope

$scope.$on('ngGridEventSorted', function(event, args) {
   var targetScope = event.targetScope;
   // inspect targetScope's properties to differentiate between the two grids
});

Another way would be to create two wrapping div's around the grids, each with their own controller that handles the event.

<div ng-controller="controllerOne">
   <ng-grid ...>
</div>

<div ng-controller="controllerTwo">
   <ng-grid ...>
</div>

Другие советы

That what you need:

$scope.$on('ngGridEventSorted', function(event,data) {
            if ($scope.gridOptions1.gridId==event.targetScope.gridId){
                ...
            }
            if ($scope.gridOptions2.gridId==event.targetScope.gridId){
                ...
            }
        });

And no need to define gridId.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top