Results 1 to 4 of 4

Thread: Nested Json, Grid Panel and Store.

  1. #1

    Default Nested Json, Grid Panel and Store.

    How do I create a panel that reads only the "ReservationDetails" if the return Json looks like this.
    Code:
    {
       "data":{
          "Id":0,
          "HotelId":6,
          "Fees":0,
          "FullName":null,
          "SocialNumber":null,
          "Email":null,
          "Phone":null,
          "Remark":null,
          "ReservationDetails":[
             {
                "Id":0,
                "ReservationId":0,
                "RoomTypeId":8,
                "DateValue":"\/Date(1333209600000)\/",
                "DayValue":"asdf",
                "IsAvailable":false,
                "RoomRates":1,
                "Quantity":1,
                "Prices":1
             },
             {
                "Id":0,
                "ReservationId":0,
                "RoomTypeId":19,
                "DateValue":"\/Date(1333209600000)\/",
                "DayValue":"asdf",
                "IsAvailable":false,
                "RoomRates":1,
                "Quantity":1,
                "Prices":1
             }
          ]
       },
       "success":true
    }

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997

    Default

    How are you getting the data? Store? Ajax request?
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  3. #3

    Default

    Hi mitchellsimoens, I'm using Store with Ajax proxy. Below is my store definition
    Code:
    Ext.define('HEB.store.Reservation', {
        extend: 'Ext.data.Store',
        requires: 'HEB.model.Reservation',
        model: 'HEB.model.Reservation',
    
        autoLoad: false,
        autoSync: false,
        proxy: {
            type: 'ajax',
            api: {
                create: '/Reservation/Create',
                read: '/Reservation/GetReservationAvailabilityForHotel',
                update: '/Reservation/Edit',
                destroy: '/Reservation/Delete'
            },
            reader: {
                type: 'json',
                root: 'data'
            },
            writer: {
                type: 'json'
            },
            extraParams: {
                'hotelId': '',
                'startDate': '',
                'endDate': '',
                'unit': ''
            },
            headers: {
                'Content-Type': 'application/json; charset=UTF-8'
            }
        }
    });

  4. #4
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,258
    Answers
    759

    Default

    Set the root like so:

    Code:
    root: 'data.ReservationDetails'
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •