This is a migrated thread and some comments may be shown as answers.

Nested object value on platform (everlive)

2 Answers 32 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Anthony
Top achievements
Rank 1
Anthony asked on 09 Nov 2015, 11:27 AM

Hi

I have nested object field in Telerik Platform (everlive data) which I want to display in a grid. 

I could only manage to display such a nested object value when hardcoding the data in JS as follow:

//HARDODED

var data = [ {  "Id": "asdads",  "surname": "asdaassadds", "healthRiskAssessment": { "totalAlcoholPerWeek": "test 59" } }];
var dataSource = new kendo.data.DataSource({
    data: data
});

$("#kendoGridExportAll").kendoGrid({
            dataSource: dataSource,
            columns: [    { field: "Id" },    { field: "surname" },  { field: "healthRiskAssessment.totalAlcoholPerWeek" }   ]
        });​

//---------------

 

But I could not get the "totalAlcoholPerWeek" field to dosplay while using everlive. See telerik data screenshot. Could you please assist?

//EVERLIVE

var dataSource = new kendo.data.DataSource({ type: "everlive", transport: { typeName: "healthRiskAssessment" }});
$("#kendoGridExportAll").kendoGrid({

            dataSource: dataSource,

            columns: [{ field: "Id" }, { field: "surname" }, { field: "healthRiskAssessment.totalAlcoholPerWeek" } ]

});​

2 Answers, 1 is accepted

Sort by
0
Anthony
Top achievements
Rank 1
answered on 09 Nov 2015, 11:29 AM
FYI. The "surname" field displays in the Everlive grid. But the totalAlcoholPerWeek is blank.
0
Anton Dobrev
Telerik team
answered on 11 Nov 2015, 09:22 AM
Hello Trev,

Most probably the reason for this behavior is that the healthRiskAssessment in the database is saved as a string and not as an object. Thus, the configuration of the Grid widget cannot access the property totalAlcoholPerWeek.

For example, the current state is:
healthRiskAssessment: {\"totalAlcoholPerWeek\" : \"23\" }

while the correct value to be used by the Grid is:
healthRiskAssessment: { "totalAlcoholPerWeek" : "23" }

You may want to examine the code that creates the value for healthRiskAssessment and adjust it to do not enter the value as a string.

Let me know if you have questions.

Regards,
Anton Dobrev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Anthony
Top achievements
Rank 1
Answers by
Anthony
Top achievements
Rank 1
Anton Dobrev
Telerik team
Share this question
or