Results 1 to 2 of 2

Thread: Forcing parent ViewModel data to be available to child

  1. #1
    Ext JS Premium Member
    Join Date
    Apr 2010
    Location
    Omaha, NE
    Posts
    631
    Answers
    10

    Default Forcing parent ViewModel data to be available to child

    I have a child view that uses data from a parent's ViewModel. In the parent's ViewController I do this:

    Code:
        initViewModel: function (viewModel) {
            var me = this;
    
    
            viewModel.bind({
                bindTo: '{record}',
                single: true
            }, me.onInitialBind, me);
        },
    onInitialBind then calls a method on the child view which does a me.getViewModel().get('record') but record isn't available yet. I got it to work putting this config on the child view. Is this a good solution?

    Code:
        viewModel: {
        },

  2. #2
    Sencha - Engineering israelroldan's Avatar
    Join Date
    Nov 2011
    Location
    The Netherlands
    Posts
    395
    Answers
    25

    Default

    View models' data and formulas are automatically inherited across child components (the components don't need to actually inherit, just to be items of a parent component). Is that what you're trying to do?
    Israel Roldán | Senior Software Engineer (Framework tools)

Posting Permissions

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