Skip to main content
Answer

Catching the row change event in a grid

  • July 20, 2023
  • 7 replies
  • 315 views

Forum|alt.badge.img+1

Hi,

I have a simple processing screen displaying records in a grid. Above the grid, I have some action buttons.

What I want to do

I'd like to change dynamically the accessibility of one of thses action buttons : if the selected record in the grid has some specific characteristics, the button is enabled, otherwise, it is disabled.

The problem  to solve

My problem is to catch the fact that a new row is selected in the grid : the RowSelected event is not invoked in this case.

Some technical details

The declaration of the graph :

public class EapActivityProcess : PXGraph<EapActivityProcess>

The declaration of the view

        public SelectFrom<EAPActivity>
            .OrderBy<Desc<EAPActivity.lastChangeDate>>
            .View.ReadOnly ActivityView;

This is the view used in the grid :

Anybody knows if it is possible ?

Best answer by Naveen Boga

@ygagnaire12  As you mentioned above below link will fulfil your requirement.

https://stackoverflow.com/questions/47877150/is-there-any-event-triggered-when-highlighting-a-row

 

And to get the current row, you should use the View.Current. Let us know if you get any issues with this?

 

7 replies

Forum|alt.badge.img+1
  • Author
  • Semi-Pro I
  • July 20, 2023

I just have found a reply that would partially fit my need :

https://stackoverflow.com/questions/47877150/is-there-any-event-triggered-when-highlighting-a-row

However, is it possible to get current record in the grid (I mean selected record). ?

 


darylbowman
Captain II
Forum|alt.badge.img+15

You need to set SyncPosition = true on the grid properties.

This will allow you to get the selected row with ActivityView.Current.


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • July 23, 2023

Hi @ygagnaire12  Can you please share your code here for our review?


Forum|alt.badge.img+1
  • Author
  • Semi-Pro I
  • July 26, 2023

Thank you @darylbowman for your suggestion, I test it.

@Naveen Boga, I have joined the code of the used DAC. For the graph, I just have the view as described in my first post. I have added a _(Events.RowSelected<EAPActivity> e) method but it is not called on grid row selection change.


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • Answer
  • July 27, 2023

@ygagnaire12  As you mentioned above below link will fulfil your requirement.

https://stackoverflow.com/questions/47877150/is-there-any-event-triggered-when-highlighting-a-row

 

And to get the current row, you should use the View.Current. Let us know if you get any issues with this?

 


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • August 22, 2023

Hi @ygagnaire12 were you able to find a solution? Thank you!


Forum|alt.badge.img+1
  • Author
  • Semi-Pro I
  • August 23, 2023

Hi @Chris Hackett !

It turned out that our needs changed and that we have given up the screen I began to work on. However, it is good to know how to do in such a case and I think that the solution exposed in this topic is a good way to do that. So, thank you to @darylbowman  and @Naveen Boga for their help.

To be completely honest, we turned to another scenario where we also need to detect when a row change in a grid, but where we do not have to enable or disable buttons. We have found a solution using the client event OnRowChanged of the grid.