Sunday, 20 November 2022

ag-grid context menu icon custom method

I have a simple context menu on an ag-grid, Alert, which when clicked calls a method alertOne()

getContextMenuItems(params: GetContextMenuItemsParams): (string | MenuItemDef)[] {
    var result: (string | MenuItemDef)[] = [
      {
        // custom item
        name: 'Alert ',
        action: () => {
          this.alertOne(params.value);
        }
      }      
    ];
    return result;
  }
}

alertOne(value: string) {
    window.alert('Alerting about ' + value);
}

I want to add an icon on the above Alert menu item, however when clicks, calls a new method alertTwo(); so would look like this on the UI:

----------------------
|  Alert        (:D) |
----------------------

With the above, if the users clicks on the text Alert, alertOne() is called. If the (:D) icon is clicked, alertTwo() is called.



from ag-grid context menu icon custom method

No comments:

Post a Comment