Results 1 to 2 of 2

Thread: Ext.data.Model & field reference

  1. #1
    Sencha Premium Member
    Join Date
    Feb 2012
    Posts
    40
    Answers
    2

    Question Ext.data.Model & field reference

    I've got a GET request ('/post/1') that returns a json like:

    PHP Code:
    id1name'foo'author: { id2name'bar' } } 
    I'd like to have a reference to the `Author` model like:

    PHP Code:
    Ext.define('App.model.Post', {
      
    extend'App.model.Base',

      
    fields: [
        { 
    name'author'reference: { type'Author'role'authorRef' } }
      ]

    }) 

    How can I get this to work when my reference data is part of my `Post` data and does not require another GET?

  2. #2
    Ext JS Premium Member
    Join Date
    Mar 2010
    Location
    Cologne
    Posts
    37
    Answers
    2

    Default

    Maybe this response is a little late, but since i (believe i) was just having the same problem.

    the reference.type should be the full qualified class name of the referenced model:
    Code:
    Ext.define('App.model.Post', {
      extend: 'App.model.Base',
    
    
      fields: [
        { name: 'author', reference: { type: 'App.model.Author', role: 'authorRef' } }
      ]
    
    
    })

Similar Threads

  1. Replies: 1
    Last Post: 18 May 2016, 4:39 PM
  2. Replies: 1
    Last Post: 24 May 2015, 7:08 PM
  3. Ext.data.field.Field reference allowBlank
    By mattjenkins in forum Ext 5: Q&A
    Replies: 1
    Last Post: 16 Jan 2015, 10:12 AM
  4. Replies: 0
    Last Post: 8 Nov 2013, 5:19 AM

Posting Permissions

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