I have a json source with items that include attributes (such as text and numbers) as well as objects {}. Can the dataAdapter and Grid read the item objects? If so, how do I set up the column to read them?
Here’s a sample json structure that I’m talking about:
var data = [
{
"salesPerson": {
"firstname": "john",
"lastname": "smith"
},
"productname": "product 1",
"price": 1,
"quantity": 2,
"total": 2
},
{
"salesPerson": {
"firstname": "jane",
"lastname": "adams"
},
"productname": "product 2",
"price": 4,
"quantity": 5,
"total": 20
},
{
"salesPerson": {
"firstname": "jane",
"lastname": "adams"
},
"productname": "product 5",
"price": 7,
"quantity": 8,
"total": 56
},
{
"salesPerson": {
"firstname": "bill",
"lastname": "brown"
},
"productname": "product 4",
"price": 3,
"quantity": 4,
"total": 12
}
];
var source =
{
localdata: data,
datatype: "json"
};
// now that the json data is built use the jqx adapter to handle the data
var dataAdapter = new $.jqx.dataAdapter(source, {
loadComplete: function (data) {
console.log("Data loaded");
console.log(data);
},
loadError: function (xhr, status, error) {
console.error("Data failed to load into jqx adapter\n\t" + status + " \n\t" + error);
}
});
/*
I tried setting up a column using
{ text: ‘First Name’, datafield: ‘salesPerson.firstname’, width: 100 },
but the column was blank
*/