JavaScript UI Libraries & Blazor Components Suite – Smart UI › Forums › Data Grid › Mapping dataField to complex JSON structure
Tagged: data binding, datagrid data binding, json mapping, smart grid
- This topic has 12 replies, 2 voices, and was last updated 2 years, 5 months ago by
admin.
-
AuthorPosts
-
November 30, 2020 at 5:48 am #101184
nikhiljainkke
MemberHi,
The example provided in the “demos” section is quite clear and uses a standard data structure,data[{Date:'', value1:7, value2:77}]
, the coresponding series have data fields value1 and value2.
I have below Complex JSON structure in my code. I am unable to bind the data.
<div>
<div>[</div>
<div> {</div>
</div>
<div>
<div> “Group”: {</div>
<div> “dataField_name_1”: {</div>
<div> “value”: null,</div>
<div> },</div>
<div>
<div> “dataField_name_2”: {</div>
<div> “value”: null,</div>
<div> },</div>
</div>
<div> }</div>
<div> }</div>
<div>]</div>
</div>
<div>previously we were using JQXGrid and they have provided “map” attribute to bind the data to Complex JSON structure.</div>
<div>datafields: [</div>
<div> { name: ’empName’ },</div>
<div> { name: ‘age’ },</div>
<div> { name: ‘id’, map: ‘department>id’ },</div>
<div> { name: ‘name’, map: ‘department>name’ },</div>
<div> { name: ‘author’ }</div>
<div>],</div>
<div> How do you map complex structures?</div>
<div></div>
November 30, 2020 at 6:22 am #101185admin
KeymasterHi Nikhil Jain,
We are working on our next release coming in mid of December which will add support for dataFields mapping, binding to CSV & TSV. At present, there is no built-in way to map fields in Smart.Grid.
Best regards,
Peter Stoev
Smart UI Team
https://www.htmlelements.com/December 16, 2020 at 3:59 pm #101242nikhiljainkke
MemberHi,
when will you have next release.
Thanks
Nikhil JainDecember 17, 2020 at 4:21 pm #101243admin
KeymasterHi Nikhil Jain,
Could you post an example how you exactly try to bind the data grid? I just want to check whether the upcoming release which is now in a test phase covers your scenario.
Looking forward to your reply.
Best regards,
Peter Stoev
Smart UI Team
https://www.htmlelements.com/December 18, 2020 at 10:27 am #101244nikhiljainkke
MemberHi Peter,
Please find the below data structure which we are using.
[
{
“Group1”: {
“Group2”: [
{
“DataField1”: [
{
“value”: “abc”
},
{
“value”: “def”
}
]
}
]
}
},
{
“Group1”: {
“Group2”: [
{
“DataField2”: [
{
“value”: “abf”
},
{
“value”: “xyz”
}
]
}
]
}
}
]
Looking forward to your reply.
Thanks
Nikhil JainJanuary 8, 2021 at 1:01 pm #101306nikhiljainkke
MemberHi Peter,
Can you please update when mapping to complex JSON will be released in Data Grid.
Looking forward to your reply.
Thanks,
Nikhil JainJanuary 8, 2021 at 1:53 pm #101307admin
KeymasterHi Nikhil Jain,
jqxGrid like mapping is now supported in the latest version. If you wish, you can try it.
Best regards,
Peter Stoev
Smart UI Team
https://www.htmlelements.com/January 26, 2021 at 7:51 am #101376dusrkdldlr
MemberCan I see an example?
January 27, 2021 at 2:29 am #101385dusrkdldlr
MemberI was solve it used template
May 11, 2021 at 1:18 pm #101790garcia
MemberI have this situation
How setting value of field company whith description value?
<div>
<div> “data”: [</div>
<div> {</div>
<div> “_id”: “605b0c6d5b99d60f23af2324”,</div>
<div> “nroOffer”: “OP0014-21”,</div>
<div> “offerDate”: “2021-01-11T23:00:00.000Z”,</div>
<div> “company”: {</div>
<div> “_id”: “5ec2a22aa41b9eeb2125180a”,</div>
<div> “description“: “ppppppp”,</div>
<div></div>
</div>May 12, 2021 at 5:00 pm #101800yavordashew
MemberHi 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/March 27, 2022 at 3:59 pm #102995JoeLaRue
ParticipantHappy to have found this… I couldn’t find it in the documentation anywhere 🙁 Did I miss it or is it just not there?
March 28, 2022 at 6:28 am #103004admin
KeymasterHi JoeLaRue,
It is in the Grid API docs. dataSourceSettings>dataFields>map
Best regards,
Peter StoevSmart UI Team
https://www.htmlelements.com/ -
AuthorPosts
- You must be logged in to reply to this topic.