0

We're using Angular UI grid to fetch and display a large dataset that can sometimes take a while to sort. We've settled on warning the user of this when they click the sort button.

So we're using:

gridApi.core.on.sortChanged( $scope, function(){
    $scope.notificationList = sharedFunctionsService.addNotification('Warning', 'Sorting may take a while to complete', $scope.notificationList);
});

We've also tried using angular bootstrap alerts. But either way, what happens is the user clicks the sort button, the sort completes and then the message appears. I know this is some async operation, but how can I tell Angular/Node to execute the notification first? Or, if there's some other way, I'd be happy to give it a try.

brandonscript
  • 68,675
  • 32
  • 163
  • 220
anthozep
  • 333
  • 5
  • 16

1 Answers1

1

You're using the on.sortChanged event, which only fires after the sort is completed. Try instead to use an onClick event, which would fire as soon as the button is clicked, and before the sort occurs.

brandonscript
  • 68,675
  • 32
  • 163
  • 220
  • When I put a `console.log()` statement in `on.sortChanged` it fired immediately. But also, I don't see `onClick` in the API. How can use `onClick` to trigger when any sort ascending or sort descending button is pushed? – anthozep Aug 21 '15 at 22:09
  • It wouldn't be a grid event, it would be a native javascript event (or Angular UI). – brandonscript Aug 21 '15 at 22:40
  • I'm not sure I know how to get at that button with an native javascript `onClick`. I did try editing the header template `headerCellTemplate` to fire a function but that didn't seem to work either. – anthozep Aug 25 '15 at 00:10