JavaScript UI Libraries & Blazor Components Suite – Smart UI › Forums › Data Grid › Mapping dataField to complex JSON structure › Reply To: Mapping dataField to complex JSON structure
May 12, 2021 at 5:00 pm
#101800
yavordashew
Member
Hi I.garcia,
I would like to share with you a code snippet which showcases the functionality you want to achieve.
dataSource: new window.Smart.DataAdapter({
dataSource: [
{
"empName": "Peter",
"age": "33",
"company": { "id": "1234", "description": "Sales" },
"author": "Johny Bravo"
}
],
dataFields: [
{ name: 'empName', dataType: 'string' },
{ name: 'age', dataType: 'int' },
{ name: 'id',map: 'company.id', dataType: 'int' },
{ name: 'name', map: 'company.description', dataType: 'string' },
{ name: 'author', dataType: 'string' }
]
}),
columns:
[
{ label: 'Name', dataField: 'empName', width: 250 },
{ label: 'Age', dataField: 'age', width: 250 },
{ label: 'Department Name', dataField: 'name', width: 180 },
{ label: 'Author', dataField: 'author'}
]
Let me know if that works for you!
Please, do not hesitate to contact us if you have any additional questions.
Best regards,
Yavor Dashev
Smart UI Team
https://www.htmlelements.com/