Joseph Caruana
Joseph Caruana

Reputation: 2271

Overwrite Add action of a grid

I have a standard Acumatica screen with a Form and a Grid. Is it possible to overwrite the Add Button of a grid, so that I can carry out a custom action rather than using the standard Add.

Upvotes: 2

Views: 1346

Answers (1)

Samvel Petrosov
Samvel Petrosov

Reputation: 7706

One of the ways is to hide the Standard Add New as I have described in the answer hide-add-button-from-grid and create your own.
Now you should create PXAction in your Graph with it's corresponding method like this:

public PXAction<SOOrder> CustomAddNew;

[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "Add New")]
protected void customAddNew()
{
    //your code here
}

After this you should go to the page and do the following:

  1. Add a button to the DataSource to Hide Action from the Action Bar of the Header in this way: Where the Name is your PXAction. enter image description here
  2. Add a button to the Grid with the following setting: Where
    ImageKey="AddNew" is for setting the Icon
    AutoCallBack.Command="CustomAddNew" is the Name of your PXAction DisplayStyle="Image" is for showing only the Icon. enter image description here

As a result you will get the following : Where the '+' is your PXAction enter image description here

Upvotes: 4

Related Questions