I am currently trying to find the best solution for the following problem.
We have some complex logic for dynamic collums in DataGrid that allows a JSON to be build up, and it works great. However when we get empty results we assign "" empty value to the Data input of the grid, which results in the grid displaying a no results placeholder in front of data that is not in the data variable anymore of the DataGrid. For context when we load an empty data input from a refresh on the screen for example we are only left with the placeholder and no old data (which is what we expected)
Screenshot on how it looks like:
I have found a discussion some years ago that seems the excact issue we are having but no true solutions yet: https://www.outsystems.com/forums/discussion/74278/datagrid-not-clean-record-if-we-update-the-data-with-an-empty-object/#Post304787
Wonder if someone knows how to deal with this
Hi @Sten Mols ,
the workaround i give in that other post already removes a lot of the problem (you end up with no data shown, and a single empty header cell.)
If it has to be EXACTLY the same as before first fetching any data, you could try something like having 2 grids in an IF, one with the data and one with no data supplied, and just show the empty one when there is no data.
Gives a little bit of a flicker, though, and it needs some testing to make sure both grids take up the same spot / space.
These are only workarounds, dynamic data in the DataGrid was never really a warmly promoted use case, and in ODC it's no longer available at all, so I wouldn't expect too much investment in fixing this on the O11 side.
Dorine
Hi @Dorine Boudry,
Yeah so bassically you need to insert only empty metadata, but then make sure that the colums matches when there would be records?
Well, i don't know exactly what JSON your current logic builds, but I would do that with both a data and a metadata section. That way, you have control over data types.
If you then want to clear the grid, you pass in JSON with as data an empty array, and as metadata a single attribute with as name an empty string. Anything less doesn't work.
Hi @Sten Mols
To help the community, helping you could you please share an oml with your use case being replicated (without any business information ofc) so we can try to look into the same use case? It would be super useful. Also, please share what you've already tried.
Cheers,GM
Hi @Gonçalo Martins,
I replicated it in the official forge component sample from OutSystems:
In the AddRemoveRows add a button > ButtonOnClick > In that action assign the DataServerSide.Data to ""
In runtime when you click the button You should see the placeholder text above current data.
I have tried to share the OML but its more than 10mb so was unable to quickly (it is probably more efficient if you recreate the above steps)
For the sake of the time of the community members here to help, the more efficient approach is for you to create a simple oml with a screen showing your use case.