0

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?

Ryan Pelletier
  • 616
  • 7
  • 20
  • do you want a custom grid menu that will be applied on selected rows? – AranS Jun 22 '16 at 09:44
  • Correct, but I do not want to put it in the columnDefs property as I have in my question. I would like to configure the menuItems property once so it applies to every column in the grid. – Ryan Pelletier Jun 22 '16 at 12:50
  • last question - you mean one menu for the whole grid? – AranS Jun 22 '16 at 14:05
  • Ask as many as you need. No, I would like menus above each column, as is the default with the sorting, and hide column option. I can accomplish what I need to do, I am just trying to avoid having to specify the same menu items for every column I have. I would like to have one menuItems property in my gridOptions, and that property to apply to each menu above each column. In my example in my question, if I were to define more columns I would have to add the menuItems property for those columns as well. (which would be the same) – Ryan Pelletier Jun 22 '16 at 14:11

1 Answers1

0

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;
}
S. Baggy
  • 950
  • 10
  • 21
  • Thank you, but I am really looking for a way where I don't need any JavaScript code whatsoever. I think I am out of luck, it doesn't look like they support it yet. – Ryan Pelletier Jul 01 '16 at 14:54