Carnaru Valentin
Carnaru Valentin

Reputation: 1875

Dynamic enable/disable "enableSorting" in ui-grid

I have problem to enable disabled sorting in ui-grid in Angular 1. I try this in grid columnsDefs:

{
  ...
  enableSorting: false
}, 

And I try to overwrite it when something is happening in my controller:

$scope.$watch("vm.verifiedCreatedRecords", function(newVal, oldVal){
  if(newVal.length > 0){ 

    vm.UpdateCreationGridOptions.columnDefs[4].enableSorting = true;
  } 
  else {
        vm.sortingCreate = false;
  }

}, true);

vm.UpdateCreationGridOptions.columnDefs[4].enableSorting become true, but the grid is not enable sorting. It remains with default status for sorting.

Also I have set for general option: "useExternalSorting: true"

Any ideas regarding how can I refresh the ui-grid? Thanks!

Upvotes: 0

Views: 276

Answers (1)

Mudassar
Mudassar

Reputation: 3225

Try below refresh approaches

$scope.UpdateCreationGridOptions.core.queueGridRefresh();
$scope.UpdateCreationGridOptions.core.refresh();
$scope.UpdateCreationGridOptions.grid.refreshCanvas();
$scope.UpdateCreationGridOptions.grid.refreshRows();

Upvotes: 1

Related Questions