Get Free Trial
Get Free Trial

Display value from child object in column

Shawn asked on March 25, 2019

I have an array of objects:
[
   {
      accountNumber: ‘123456’,
      balance: 100,
      customer: {
            firstName: ‘Mike’,
            lastName: ‘Smith’
      }
   },
   …
]
 
How can I get a column called ‘Customer’ and in each row it displays customer.firstName + ‘ ‘ + customer.lastName
 
I’m making a simple grid with column headers and each row is the data.
 
 

2 answers

Public
Vera Didenko Flexmonster March 25, 2019

Hello, Shawn,

Thank you for your question.

Please note that Flexmonster supports only two JSON formats:

1) An array of objects:
 

var jsonData = [
{
"Color" : "green",
"Price" : 174,
"Quantity" : 22
},
{
"Color" : "red",
"Price" : 170,
"Quantity" : 20
}
]

 
2) An array of arrays:

var jsonData = [
[
"Category",
"Color",
"Price",
"Quantity"
],
["Ice-cream", "red", 23.32, 4],
["Ice-cream", "yellow", 4.2, 3]
]

 
The JSON format you are using is not among the supported ones.

 
A possible workaround is to pass a JSON of the following format:

var jsonData = [
{
accountNumber: 123456,
balance: 100,
customer: "John Wind"
},
{
accountNumber: 123498,
balance: 180,
customer: "Ann Miles"
}
]

 
In this case, the data will be displayed in the desired way.

Please let us know if this works for you and if you have further questions.

Best Regards,
Vera

Public
Shawn March 25, 2019

Thank you for the prompt reply, I will have to work around this limitation and just flatten the data.

Please login or Register to Submit Answer