Fields in Web Service Data Source

6 posts, 0 answers
  1. Mirzodaler
    Mirzodaler avatar
    4 posts
    Member since:
    Jun 2014

    Posted 22 May Link to this post

    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?

  2. Katia
    Admin
    Katia avatar
    693 posts

    Posted 22 May Link to this post

    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
  3. Mirzodaler
    Mirzodaler avatar
    4 posts
    Member since:
    Jun 2014

    Posted 23 May Link to this post

    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,

     

  4. Todor
    Admin
    Todor avatar
    182 posts

    Posted 25 May Link to this post

    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
  5. Andrey
    Andrey avatar
    1 posts
    Member since:
    May 2018

    Posted 27 May in reply to Katia Link to this post

    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?

  6. Todor
    Admin
    Todor avatar
    182 posts

    Posted 30 May Link to this post

    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
Back to Top