Results 1 to 2 of 2

Thread: How does Model and ViewModel work together

  1. #1
    Sencha Premium Member
    Join Date
    Jan 2008
    Location
    Denmark
    Posts
    28

    Default How does Model and ViewModel work together

    I have read the documentation regarding Viewmodels, which I'm looking forward to trying out. I'm missing something in the documentation though.

    If you have a complex Model hierarchy, how do you tell the ViewModel to use data from a specific Model instance?

    I have this from the documentation:
    Code:
    Ext.create('Ext.Component', {
        bind: {
            data: {
                reference: 'User',
                id: 42
            }
        }
    });
    But when you write the code for the ViewModel, you generally don't know what the id of your Model instance will be.

    I'm missing a ViewModel.setRecord(model) method. Am I the only one?

    Does anybody have an example of how to accomplish what I need?

    Thanks.

  2. #2
    Sencha User
    Join Date
    Nov 2014
    Posts
    3,120
    Answers
    446

    Default

    Hi--

    You can always create a link via the API when needed:

    https://docs.sencha.com/extjs/6.0/6....-method-linkTo

    Thanks!
    Joel

Similar Threads

  1. Combobox bind Viewmodel>link>model doesn't work
    By gustavobuenno in forum Ext JS 6.x Q&A
    Replies: 3
    Last Post: 14 Aug 2015, 6:19 AM
  2. ViewModel and Model
    By fabioebner in forum Sencha Ext JS Q&A
    Replies: 5
    Last Post: 2 May 2015, 4:00 PM
  3. ViewModel + Store + model
    By fabioebner in forum Sencha Ext JS Q&A
    Replies: 1
    Last Post: 17 Sep 2014, 2:04 PM
  4. ViewModel - should I require store and model?
    By LesJ in forum Ext 5: Q&A
    Replies: 3
    Last Post: 24 Apr 2014, 12:41 PM
  5. Replies: 7
    Last Post: 7 Apr 2014, 6:34 PM

Posting Permissions

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