40
Views
2
Comments
Solved
Data Grid - [object Object] unable to access values
Question

Hello!

I'm trying to get the datagrid to work for me, but unfortunatelly i've got some issues with the data access.

I'm starting with getting data:

Structures that i use:

and so, the table looks like this:

I need to create columns from the "WarehouseAmount" list, that's the JSON that i've got:

{"data":[{"Name":"Cisco Catalyst 2960S-48LPS-L","WarehouseAmount":[{"Amount":0,"Warehouse":"warehouse1"},{"Amount":0,"Warehouse":"warehouse2"},{"Amount":0,"Warehouse":"warehouse3"},{"Amount":0,"Warehouse":"warehouse4"},{"Amount":8,"Warehouse":"warehouse5"}]}

I need to create separete column for each warehouse with the amount assigned to it.

Any ideas?

2021-09-06 15-09-53
Dorine Boudry
 
MVP
Solution

Hi @Krzysztof Prokop ,

I'm assuming you are going with auto-generated columns on the grid to do this, right ?  As you don't know upfront the number and names of the warehouses ?

So, your data should have the shape :

     {"Name":"Cisco Catalyst 2960S-48LPS-L","warehouse1":0,"warehouse2": 0,"warehouse3:0,"warehouse4":8},
     {"Name":"Cisco Catalyst xxxxxxxxxxxxx","warehouse1":2,"warehouse2": 0,"warehouse3:0,"warehouse4":3,"warehouse5": 12}
]} 


If you don't know upfront what your warehouses will be, you can't create this as a structure to push into ArrangeData, so I'm not sure there is any way of doing this with ArrangeData action.  

I personally would make the JSON by hand, but OutSystems strongly emphasises that you should use ArrangeData and not bake your own cake.  It's up to you how you feel about that.

To be complete, your self made logic to replace the ArrangeData part, should result in something like (maybe you like to add an extra layer of entity name in there or not, up to you):


{

"data":[

     {"Name":"Cisco Catalyst 2960S-48LPS-L","warehouse1":0,"warehouse2":4,"warehouse3":8,"warehouse4":0}, {"Name":"Cisco Catalyst xxxxxxxxxxxxx","warehouse1":2,"warehouse2":4,"warehouse4":0,"warehouse5":2} ], "metadata": {"Name":"String","warehouse1":"Int32","warehouse2":"Int32","warehouse3":"Int32","warehouse4":"Int32","warehouse5":"Int32"} }

 

Dorine


UserImage.jpg
Krzysztof Prokop

Hi!

Thank you for the response.

I've ended up getting the needed data from SQL query then i'm making the JSON by hand based on the structure that i've got from the query result.

:)

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