Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    REST datasource with JSON

    in REST datasource show case, I want to client send JSON and consume JSON
    so I add one line

    Code:
    countryDS.setDataFormat(DSDataFormat.JSON);
    and I find grid send retrieve http request as following

    Code:
    {
          "dataSource": "mydatasource", 
          "operationType": "fetch", 
          "data": null, 
          "oldValues": null
    }
    and my backend response JSON as following
    Code:
    {
        response:{
            status:0,
            startrow:0,
            endrow:3,
            totalrows:3,
            data:{
                record:[
                    {
                        continent:'North America',
                        countryname:'United States',
                        countrycode:'US',
                        area:9631420,
                        population:298444215,
                        gdp:12360000,
                        independence:'1776-07-04',
                        government:'federal republic',
                        government_desc:2,
                        capital:'Washington, DC',
                        member_g8:'true',
                        article:'http://en.wikipedia.org/wiki/United_states'
                    },
                    {
                        continent:'Europe',
                        countryname:'Germany',
                        countrycode:'GM',
                        area:357021,
                        population:82422299,
                        gdp:2504000,
                        independence:'1871-01-18',
                        government:'federal republic',
                        government_desc:2,
                        capital:'Berlin',
                        member_g8:'true',
                        article:'http://en.wikipedia.org/wiki/Germany'
                    },
                    {
                        continent:'Europe',
                        countryname:'United Kingdom',
                        countrycode:'UK',
                        area:244820,
                        population:60609153,
                        gdp:1830000,
                        independence:'1801-01-01',
                        government:'constitutional monarchy',
                        government_desc:1,
                        capital:'London',
                        member_g8:'true',
                        article:'http://en.wikipedia.org/wiki/United_kingdom'
                    },
                    
                ]
            }
        }
    }
    but nothing show on Grid, and no any warning or exception show on debug console, anyone has idea about this?

    #2
    That response does match the expected RestDataSource format. The "data: { }" wrapper should be removed and "records" should be named "data". The metadata is also not capitalized correctly. See the RestDataSource docs for details.

    Comment


      #3
      Originally posted by davidj6
      That response does match the expected RestDataSource format. The "data: { }" wrapper should be removed and "records" should be named "data". The metadata is also not capitalized correctly. See the RestDataSource docs for details.
      davidj6:

      Thanks for your help, I will retry it.

      Comment

      Working...
      X