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

Fields in Web Service Data Source

5 Answers 886 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mirzodaler
Top achievements
Rank 1
Veteran
Mirzodaler asked on 22 May 2018, 11:47 AM

I got a R2 2018 release of telerik reporting and excited about having Web Service Data Source option to connect to my OData REST service end point to retrieve the data.

Let's say that my web service endpoint responds below JSON:

{
    "@odata.context": "My Context",
    "value": [
        {
            "ShippingCompleted": false,
            "TransactionDate": "2017-05-12T00:00:00+05:00",
            "ShippingName": "Eshmatov Eshmat", 
            "Address": {

                       "City": "Serviceland"

             }  

        }
    ]
}

If you look on an attached image, the data explorer contains a data source which have only two fields. The first is string (@odata.context) and second is Object (value).

For example, on report I want to have an access to City filed  [=Fields.value.Address.City] or ShippingName field [=Fields.value.ShippingName]. This is not working and it is showing the System.Object [] in report. As well in data explorer there is no way to see what fields the value field have.

Is it a bug, or it is designed for one level of json tree? Is there any workaround for this?

5 Answers, 1 is accepted

Sort by
0
Katia
Telerik team
answered on 22 May 2018, 03:01 PM
Hi Mirzodaler,

When the returned field is a collection of items with inner properties we do not drill down into the hierarchy to show the inner properties.

To display the properties values in report, you can use a separate data item which is bound to the collection field via bindings. The approach would be similar to step 8 of How to: Connect to Google Books APIs tutorial. 

More detailed information can be found in How to Databind to Collection Properties KB article.


Regards,
Katia
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Mirzodaler
Top achievements
Rank 1
Veteran
answered on 23 May 2018, 05:54 AM

Thank you Katia, I got it. The article was very helpful.

What if I want to use the inner properties for report parameter available values? Can we have some computed calculated fields which is bind to the inner properties of the data source? I am trying to understand the right way of doing that without hacks.

Thank you,

 

0
Todor
Telerik team
answered on 25 May 2018, 02:39 PM
Hi Mirzodaler,

Report Parameters property AvailableValues can have only a Data Source component as a DataSource. It will take only two fields of this source - those specified as Name and Value, as explained in the ParameterValue Class article. The other properties will be ignored.

If the property is NOT a collection, you can choose an inner property to be Name/Value of the report parameter. All public inner properties will be resolved with reflection and will be available to drill down in the report designers.

The above is valid also for the Calculated Fields.

If a Report Parameter should take a collection that is a Field or inner property of a DataSource field, it will be necessary to create a dedicated DataSource component containing only the corresponding collection.

Regards,
Todor
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Andrey
Top achievements
Rank 1
answered on 28 May 2018, 02:30 AM

Hi Katia,

I want to place several schedules in one report, using Web Service Data Source. I have data:

{"ContentEncoding":null,
"ContentType":null,
"Data":[
            {
              "NAME_01":"graph1",
               "INDICATOR_01":[
                                           {
                                           "DATE_CREATE":"03.05.18",
                                           "VALUE":5.0,
                                           "VALUE_01":0.0,
                                           "VALUE_02":4.0
                                            },
                                            {
                                             "DATE_CREATE":"04.05.18",
                                             "VALUE":5.0,
                                             "VALUE_01":0.0,
                                             "VALUE_02":5.0
                                             }
                                            ]
             },{
             "NAME_03":"graph2",
             "INDICATOR_02":[
                                         {
                                         "DATE_CREATE":"03.05.18",
                                          "VALUE":5.0,  
                                          "VALUE_01":null,
                                          "VALUE_02":null
                                           },
                                           {
                                           "DATE_CREATE":"04.05.18",
                                            "VALUE":5.0,
                                             "VALUE_01":null,
                                              "VALUE_02":null
                                             }
                                             ]
                 }]

I used Binding and I can receive only Fields.NAME_01.

As to me to receive Fields.INDICATOR_01.VALUE_01, Fields.INDICATOR_01.VALUE_02?

0
Todor
Telerik team
answered on 30 May 2018, 03:32 PM
Hi Andrey,

To dig further into the inner data fields of a collection it will be necessary to nest a new data item (for example a List named newList) into the item, which DataSource uses the (collection) field from the original data source. The newList DataSource should be bound to Fields.INDICATOR_01 and in newList the inner properties of INDICATOR_01 should be accessible as Fields.VALUE_01, etc.

Regards,
Todor
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Mirzodaler
Top achievements
Rank 1
Veteran
Answers by
Katia
Telerik team
Mirzodaler
Top achievements
Rank 1
Veteran
Todor
Telerik team
Andrey
Top achievements
Rank 1
Share this question
or