Hello,
I have a json with nested arrays. Like this:
[{
"id": 1,
"name": "John Black",
"main_email_id": 1,
"emails": [{
"id": 1,
"email": "john.black@example.com"
}, {
"id": 2,
"email": "jblack@example.com"
}]
}, {
"id": 2,
"name": "Fred White",
"main_email_id": 4,
"emails": [{
"id": 3,
"email": "fred@example.com"
}, {
"id": 4,
"email": "white@example.com"
}]
}]
I would like to load it into jqxDataAdapter and use it in simple forms and jqxGrid. So there are two tasks:
1) To use in simple form I have to get record with specified id from the data adapter using JavaScript. I can iterate through dataAdapter.records but records doesn’t have nested arrays (record doesn’t have “emails” field in my case) if I initialize data adapter like this:
var source =
{
datatype: "json",
datafields: [
{ name: 'id', type: 'int' },
{ name: 'name', type: 'string' },
{ name: 'maint_email_id', type: 'int' }
],
id: 'id',
url: url
};
var dataAdapter = new $.jqx.dataAdapter(source);
How should I initialize data adapter (how to describe datafields array in source parameter) to be able access nested arrays. I read about mapping fields but it deals with nested objects. But how to deal with nested arrays?
2) The task is to show in the jqxGrid name and main email which should be get from the nested array according main_email_id. Is it possible to do with field mapping? Or somehow else?
I spent a lot of time looking for solution but failed. Could you help me with advice, please?
Thank you,
Alexander