Suming value of child table in parent table
Suming value of child table in parent table
in Editor
Hello,
I refer to the parent child editor.
Is there a way to, instead of counting the number of users
{
data: 'users',
render: (data) => data.length
}
We make the sum of a users' field, for example their age?
I found this post but I am not sure it is pointing me in the right direction.
Thanks and regards
Answers
You should be able to make any calculations you want. Looking at the developer tools for the JSON response in the example you linked to this shows an example of one row of data in the parent:
The
columns.renderfunction is just presenting the length of theusersarray. Thecolumns.renderfunction will need changed depending on your data structure. Please provide an example of a row of data so we can help with suggestions.Kevin
I tried the follwing (dummy example)
without success
In the example you mentioned, the only value in the
usersarray is an id (per the JSON that Kevin shows in his post above). There isn't a.phoneparameter to access under the objects in that array. You could sum the.idparameter, although that isn't exactly useful! You'd need to make sure that the returned JSON includes whatever value it is that you wish to sum.Allan