[Data Grid Reactive] How to retrieve all grid ids from the screen?
Forge component by OutSystems R&D
Application Type
Reactive

Hello,

Currently I am trying to retrieve all the Grid ids from a screen.
For example: there are three different grid in a screen.
In traditional DataGrid, it is possible to retrieve all the grid ids with following script:

var gridIdList = [];

for (var i = 0; i < GridOS.GridObject.length; i++) {
   gridIdList.push(GridOS.GridObject[i].grid.gridId);
}

 Is there any way to retrieve all the grid ids from the screen with DataGrid Reactive?

Please let me know.
Thank you.

Solution

Hello @Alam,

You can use the new GridAPI method to retrieve that information in version 2.3.1.

Use a JavaScript node to call:

Kudos to @Ruben Goncalves

Bruno Martinho

Hello @Alam ,

Currently we are not exposing all the grid Id that are on the screen in the GridAPI.GridManager.

You can take a look at the Data Grid source code in Github. You can see that there is a map that contains all the grids in the screen but we are not exposing it:

outsystems-datagrid-reactive/code/src/GridAPI/GridManager.ts

 

Can you share a little bit more the need for this feature?

Thanks,

Bruno Martinho

Hello @Bruno Martinho
Thank you.
The use case is as follows:
There are two grids in the same screen. User edits some rows from both Grids and without saving the changes, if user close the browser tab, there is a script which will check if there is dirty/unsaved rows on the both Grid.

Although it is possible to get those unsaved rows with the client action getChangedLines. 
But it will take only one GridId as parameter. Also, with all GridId we can manipulate/customize the Grid in different approach.

So, is it possible to expose that map which contains all the Grid id from the screen?
Also, is there a plan to expose this?

Thank you.

I don't know if it'll do the job but I had a similar problem and I fixed it by getting the id of all the elements with the datagrid ClassName:


// Get all the grid elements from page

gridList = Object.values(document.getElementsByClassName("datagrid-autogenerate"));


mvp_badge
MVP

Hi @Alam,

Thank for your clarification. We are thinking in exposing the map, but before we do so, I would like to understand a little better your use case:

  1. Why don't you have access to IDs of the grid in the page?
  2. Are you listing the grids in the page?
  3. Do you have the grids inside other blocks?

Thank you in advance for your cooperation.

Cheers,
RG

Solution

Hello @Alam,

You can use the new GridAPI method to retrieve that information in version 2.3.1.

Use a JavaScript node to call:

Kudos to @Ruben Goncalves

Bruno Martinho

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