Load JSON data into a DataGrid

Hi,

I’m wondering if it possible to load JSON array data into a DataGrid control or if it is possible to show the data into a tabular view.

Thank you!

Regards,
Ivan

Hi Ivan,

Yes, you can. I’ll build you a sample on how to use JSON data.

Dawie

1 Like

Hi Ivan,

You can do so by using a SetValue action and assigning the Target to DataGrid.Data and the Value to your json array.

If you have a DataGrid with the columns Column1, Column2 & Column3, the format of your json should look like:

[
	{'Column1': 'My data in Row1Col1', 'Column2': 'My data in Row1Col2', 'Column3': 'My data in Row1Col3'},
	{'Column1': 'My data in Row2Col1', 'Column2': 'My data in Row2Col2', 'Column3': 'My data in Row2Col3'},
	{'Column1': 'My data in Row3Col1', 'Column2': 'My data in Row3Col2', 'Column3': 'My data in Row3Col3'}
]

See https://help.stadium.software/Controls/DataGrid for more info.

Cheers,
Nirav

Please find below a quick example. I’ve taken screenshots you can recreate:

I started with a new Application and added a Grid:

Then, for the Grid, I defined 2 Columns, “Name” and “Phone”.

Under your StartPage.Load event:

I got some JSON which contained a List of “name” and “phone” fields (I just assigned it straight into a Variable, but normally you would get it from a web-service.):

Screenshot 2020-05-15 at 12.55.17

Then you assign the value to your Grid Data:

Screenshot 2020-05-15 at 12.55.27

You need to map the data (little pencil icon on the right):

And done:

Here’s my example solution attached:

ShowJSON.sapz (8.1 KB)