Hello,
I have an object data source pointing at a of List<DynamicJsonObject>. The problem is that the report throws an error when I reference a field name because it doesn't think the field exists. So, if I create a textbox and do "=Fields.LocationName", it gets an error when I preview it. However, this code works:
private void detail_ItemDataBound(object sender, EventArgs e)
{
var detail = (Telerik.Reporting.Processing.DetailSection)sender;
Telerik.Reporting.Processing.TextBox txt = (Telerik.Reporting.Processing.TextBox)Telerik.Reporting.Processing.ElementTreeHelper.GetChildByName(detail, "txtLocationName");
var data = (dynamic)detail.DataObject.RawData;
txt.Value = data.LocationName;
}
This is presumably working because I can cast the raw data as dynamic.
I'm not wedded to this way of doing this, but I do need a way to report on json data. Is this possible?
Thanks.
7 Answers, 1 is accepted
Dynamic objects are not supported by ObjectDataSourceComponent out-of-the-box as the reporting engine expects the collection to contain a list of business objects with known properties.
You can check the approach suggested in How to: Use ObjectDataSource with ExpandoObject KB article where a custom descriptor is provided in order to determine the actual properties of the object.
You can test modifying the suggested approach to work in your particular scenario and with the type of objects you use.
Regards,
Katia
Telerik by Progress
I am trying to conver JObject to an anonymous type. Maybe somebody can help me.
http://stackoverflow.com/questions/40507909/convert-jobject-to-anonymous-object
I am trying to find different solutions.
http://stackoverflow.com/questions/40507909/convert-jobject-to-anonymous-object
It is not in our short-term plans to add support for dynamic types by ObjectDataSource component.
You can still test if the approach provided in How to: Use ObjectDataSource with ExpandoObject KB article can be useful in your scenario.
Regards,
Katia
Telerik by Progress
I found a solution, maybe telerik can help us by supporting json data as datasource object.
http://stackoverflow.com/a/40532370/202036
For JSON data, the recommended approach is first to deserialize it and then use in ObjectDataSource.
Regards,
Katia
Telerik by Progress