Skip to main content
Solved

When clicking AddNew on a grid, is there an action that is fired?


Joe Schmucker
Captain II
Forum|alt.badge.img+2

Another developer asked this question, but there was no answer to the question in terms of actually overriding the AddNew action on a grid.

When I click AddNew on the grid, I want to default a value in one of the grid fields based on a value in a filter.  When you click AddNew, it adds a blank row.  I don’t see any event that is being fired when you click that button.  As such, I think the only thing I can do is to override the AddNew action and populate the value in the override.

As suggested in the above mentioned post, the suggestion is to use RowInserting.  That event does not fire when you click the AddNew button.  It fires when you leave the row.

This is a custom form, not an extension.  

This is my code.  In debug, the breakpoint on TEST is not hit.

        [PXOverride]
        public PXAction<ICSFSSScheduleLine> AddNew;
        [PXUIField(DisplayName = "Add New", Enabled = true)]
        [PXButton(DisplayOnMainToolbar = false)]
        public void addNew()
        {
            var test = "TEST";
        }
 

I tried to catch it in the FieldDefaulting event for the field, but that doesn’t get fired either.

        protected void _(Events.FieldDefaulting<ICSFSSScheduleLine, ICSFSSScheduleLine.lower> e)
        {
            var test = "TEST";
        }

The purpose for doing this is to prevent entry errors (PEBKAC).

Is this possible?  Do I need to use a delegate?  If so, I’m not able to find what the original code is I need to override.  

Best answer by Naveen Boga

@Joe Schmucker  When we click on the Add New (+) button, by default Row_Inserted and Row_Inserting will be invoked. In your case, if it is not invoking then you might have missed to add the attribute for that gird  i.e. InitNewRow="True". Please find the screenshot for reference.

As I mentioned in the previous post, no need of adding AddNew button at all. 

 

Hope this helps!

 

View original
Did this topic help you find an answer to your question?

2 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3405 replies
  • Answer
  • June 24, 2024

@Joe Schmucker  When we click on the Add New (+) button, by default Row_Inserted and Row_Inserting will be invoked. In your case, if it is not invoking then you might have missed to add the attribute for that gird  i.e. InitNewRow="True". Please find the screenshot for reference.

As I mentioned in the previous post, no need of adding AddNew button at all. 

 

Hope this helps!

 


Joe Schmucker
Captain II
Forum|alt.badge.img+2
  • Author
  • Captain II
  • 453 replies
  • June 24, 2024

Thanks @Naveen Boga .  That is what I needed.  It now fires RowInserting.  I have one more thing to figure out on this screen and I think it will be perfect.

I’m sure this will come up for me again in two years.  I now have the answer to search for and this post will come up!  😊


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings