I need to display as a table the following information: (example)
[{
"Id":1,
"Name":"Person1",
"BirthDate":"0001-01-01T00:00:00",
"Email":"[email protected]",
"Telephone":null,
"Notes":null,
"Currency":{
"Id":1,
"Name":"EUR"
},
"CurrencyId":1,
"Translations":[
{
"Id":1,
"SourceLanguage":{
"Id":3,
"Name":"Amharic"
},
"SourceLanguageId":3,
"TargetLanguage":{
"Id":16,
"Name":"Cherokee"
},
"TargetLanguageId":16,
"Service":{
"Id":6,
"Name":"Legalization"
},
"ServiceId":6,
"Price":15,
"UnitMeasure":null,
"UnitMeasureId":1
},
{
"Id":2,
"SourceLanguage":{
"Id":3,
"Name":"Amharic"
},
"SourceLanguageId":3,
"TargetLanguage":{
"Id":16,
"Name":"Cherokee"
},
"TargetLanguageId":16,
"Service":{
"Id":7,
"Name":"Recording"
},
"ServiceId":7,
"Price":12,
"UnitMeasure":null,
"UnitMeasureId":2
}
],
"Rating":0
}]
As an example, I would like to have something like this (if it's not possible, can you at least suggest me something closer to this?):
| Name | Currency | Source Language | Target Language | Price | Service |
----------------------------------------------------------------------------------
| Person1 | EUR | Amharic | Cherokee | 15 | Legalization |
| Person1 | EUR | Amharic | Cherokee | 12 | Recording |
As you can see, if a person has multiple translations I would like to duplicate the row for every translation it has. I can ultimately change my api implementation to return the data in another way, but that would mean to load the server with the work of iterating etc and I don't want that. Currently, this is part of my datatable code (that doesn't work at all for the translations part)
var table = $("#vendors").DataTable({
ajax: {
url: "/api/vendors",
dataSrc: ""
},
columns: [
{
data: "Name",
defaultContent: "-"
},
{
data: "Currency.Name",
defaultContent: "-"
},
{
data: "Translations.SourceLanguage.Name",
defaultContent: "-"
},
{
data: "Translations.TargetLanguage.Name",
defaultContent: "-"
},
{
data: "Translations.Price",
defaultContent: "-"
},
{
data: "Translations.Service.Name",
defaultContent: "-"
}
]
});