[OutSystems Data Grid] if first column empty then DataGrid hides the column in all rows
data-grid-reactive
Reactive icon
Forge component by Platform Maintenance
Application Type
Reactive
Service Studio Version
11.14.14 (Build 59923)

i have a table with Data where first Name column is empty (Name:"")

But there is data inside other rows

If I use DataGrid to show Data with JSONSeralize it hides Name Coulmn


If I use DataGrid to show Data with ArrangeData it showa the Name Coulmn 


For my logic i cannot use ArraangeData. The only option i have is JSONSeralize  but it is hiding the Name Column.

Banking.oml

Hello,


Have you tried using Serialize Default Values as true?



yes still the same
https://hamza-gulzar.outsystemscloud.com/Banking/TestingJSONSerialize?_ts=637860927745827817


Hi,

I can get the same behaviour when testing.  This is not solved by putting 'Serialize Default Values' to Yes.  See attached oml.

Obviously, when using SerializeJSON, there is no metadata available, so the Datagrid component has to figure out what columns it should generate.  Apparently it looks only at the first row of data to do this, and apparently, a piece of data with the value "" leads to a whole column not being shown.  I think both are poor choices, and if DataGrid endorses being used in combination with json serialize, this could be considered a bug.

That being said, @Hamza Gulzar , why not make use of the ArrangeData action, why are you saying that you can not use it ??  If your truly can't use it, I guess an option would be to manually mimic it, by adding the metadata to the result of the Serialize action...but that's an ugly option in my opinion.  (see grid 4 in example oml.)

Dorine

P.S.

@Hamza Gulzar when sharing an oml to demonstrate a problem, please pay attention to dependencies, your oml could not be implemented because it has dependencies to a theme and a sample module.


QDRDataGrid.oml

Sorry about the OML

my metadata is always dynamic, i dont know how many fields are there going to be in JSON that's why i cannot use Arrange data and add  hardcoded metaData in string.

Is there a way in runtime to generate metadata from JSON?

Euhm,

There is always a way 😉 

But I´ m still not getting it, if you have a structured list available to do a json serialize on, you can also do an arrange data on that same list, right ?

In case you really can´ t, I think you have 2 options :

1) The piece of code that is producing your dynamic data, has the most intimate  knowledge of it´ s structure, and also produces the metadata.

Example : if the producer selects data from an Outsystems entity in some dynamic way, it could use the Outsystems system tables to produce the metadata. 

2) or if that is not an option, the consumer will have to analyse the json data and deduce the metadata.

You could check out JSON tools in the forge to help you with this.

Dorine

in real time scenario i don't have structured list . JSON is created on the base of bunch of conditions from services and then it is passed to DataGrid.

How i can do the 2nd option

AND i also 6,7 grids on which this is happening. so i really need to create a general action to fix all of them

Ok, 

You´ ll have to use your imagination, I guess.  I have done option 1 before, but not option 2.

If you as a human look at some JSON string, how would you decide what columns are needed  ?  How would you decide what format they are in.  Your code will have to do the same.

There are probably tools in the forge that can turn a json into some sort of structure to help you with this.  You´ ll have to experiment.

If I have time, I ´ ll take a look tonight.

I had a quick look, but trying to make your own metadata based on the json is cumbersome, it's easy enough to find a list of what columns are involved, but you'll have to execute logic to identify the data type of each based on the data in your json.  

If data type is not extremely important for you, you could pretend they are all String to avoid all this extra work and see what you get.  I find this very unsatisfactory.

In the end, this is a bug in the datagrids ability to generate columns based on random json, so if you need this for a professional project, maybe report this as a bug to OS ??  

Notice that there are more problems when not using ArrangeData, for example the representation of empty dates.

Good luck with it,

Dorine

we can use this OML instead


QDRDataGrid.oml

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