Ryan Pelletier
Ryan Pelletier

Reputation: 706

Angular UI Grid - Configure menu items globally for all columns

I know I can configure ui-grid to show extra menu items on a per column basis, such as the following.

 $scope.gridOptions = {

    "data": "results.values",
    "columnDefs": [
    { "name": "Employee Number",
      "field": "emp_no",
      "menuItems":[
          {
              "title":"Sort All Asc",
              "action":function(){console.log('test')}
          }
      ]
    }
   ]
}

Is there any way I can do this not in the columnDefs property, so that an item will be applied to all columns?

Upvotes: 0

Views: 672

Answers (1)

S. Baggy
S. Baggy

Reputation: 958

After you specify your gridOptions, you can do the following

for (var i = 0; i < $scope.gridOptions.columnDefs.length; i++) {
    $scope.gridOptions.columnDefs[i].menuItems = yourMenuItemsArray;
}

Upvotes: 0

Related Questions