[Data Grid Reactive] Is it able to get validationStatus of a cell given row & column
Forge component by OutSystems R&D

I am trying to make a reactive context menu, where if the data in active cell when right clicking on the Data Grid component is invalid, then there is another custom option displayed to fix the data (in this example, possible colors - see picture). For that, I need some way to check if the selected cell has valid or invalid data. I wanted to know if there is any way possible to do this, somthing like:

GridAPI.GridManager.GetGridById(GridId).getMetadata()[RowNumber][DataStruct][ColumnID].ValidationStatus


PS: also for some reason when displaying Submenus in the context menu if they are displayed towards the top the list skips one line, I think it might be a bug (see image)


Hello @Takeru Mazuelos,

In order to achieve your requirement it is necessary to change a little bit the Data Grid source code. The changes aren't complex and they will be incorporated in  future release, so for now it is necessary to override the code using a script in your own application.

You can check the script in the sample OML.

After that, you need to use the OnReady action for the page that has the grid and register on the ContextMenuToggle event. It is necessary to create an action to be set as callback that has two input parameters: GridID (Text) and IsOpening (Boolean).


On the callback, it is necessary to have the logic to change a screen variable that is used in an IF that is surrounding the Custom Menu Item that you need.

It is necessary to check if only one row is selected when the Context Menu is open and then check if the row is invalid (it is necessary JS for that).

The implemented sample has a validation in field Product Name, if it doesn't start with an # then it will show as invalid. As soon as the row in invalidated, then using the context menu in that row, it shows the option "Fix product name : "[The product Name]". When clicking the option, the Product Name content gets the prefix # and it is updated, as you can check in the image.

In attachment, you can find a sample OML with this implementation.

Please keep in mind that this hasn't been tested for all possible use cases or that it cover all of your requirements, so we cannot assure that it will work for all use cases.

Please let us know if this helps.

Bruno Martinho


ChangeContextMenu.oml

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.