Results 1 to 2 of 2

Thread: How to set DataView's Store to be model's associated Model?

  1. #1
    Sencha User
    Join Date
    Nov 2012
    Location
    London, UK
    Posts
    17
    Answers
    1
    Vote Rating
    2
      0  

    Default Answered: How to set DataView's Store to be model's associated Model?

    I have a dataset loading via JSON into a Store which is represented by 3 models. The models pretty much exactly reflect the structure of the JSON as such I have the following:

    JSON:
    Code:
    {
       "Client":{
          "Id":"123456",
          "Title":"Mr",
          "FirstName":"Joe",
          "Surname":"Blogs",
          "Booking":[
             {
                "BookingNodeId":123456,
                "Origin":"London",
                "Destination":"Paris"
             },
             {
                "BookingNodeId":1234567,
                "Origin":"London",
                "Destination":"Dubai"
             },
             {
                "BookingNodeId":12345678,
                "Origin":"London",
                "Destination":"Tokyo"
             }
          ],
          "Contact":[
             {
                "Name":"Steve",
                "PhoneNumber":"08001231234"
             }
          ]
       }
    }
    Models:
    Code:
    Client:
        Id, Title, FirstName, Surname
        HasManyAssociation: Booking
        HasManyAssociation: Contact
    
    Booking:
        BookingNodeId, Origin, Destination
    
    Contact
        Name, PhoneNumber
    Store:
    Code:
    ClientStore
        JSONReader loads the JSON and has implicitIncludes set meaning that the Client, Bookings and Contacts models are all loaded and setup at the same time (which is exactly what I want).
    If I set the Store property of my DataView to be the ClientStore, everything works fine provided I set the properties in my DataViewTemplate to be Client.Booking.Origin for example.

    What I want to know is how I can set the Store of my DataView to be a sub-model of my Client model. For example how would I set it so that the Bookings were the items that are bound to the DataView?
    do I need to set up another Store or do I need to refactor in some other way?

    Thanks

    Chris

  2. If you have a hasMany association then it will create a store to hold the records so you would have to use that store on the dataview.

  3. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,339
    Answers
    3887
    Vote Rating
    1297
      0  

    Default

    If you have a hasMany association then it will create a store to hold the records so you would have to use that store on the dataview.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Tags for this Thread

Posting Permissions

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