Results 1 to 2 of 2

Thread: viewModel.set() and hierarchy

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

    Default viewModel.set() and hierarchy

    I have a LoginController that does a

    Code:
                viewModel.set({
                    username: data.session.user,
                    database: data.session.dsn
                });
    username and password aren't defined in LoginModel but in its parent MainModel. Doing the set() like above actually adds it to the LoginModel but I want it in the MainModel. Is there any way to have set() look up the parent chain and only set if defined on data{}? I can do a viewModel.getParent().set() but then I need to know how far up it is which could cause problems if hierarchy changes.

  2. #2
    Sencha Premium User
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    2,372
    Answers
    20

    Default

    Quote Originally Posted by estesbubba View Post
    I have a LoginController that does a

    Code:
                viewModel.set({
                    username: data.session.user,
                    database: data.session.dsn
                });
    username and password aren't defined in LoginModel but in its parent MainModel. Doing the set() like above actually adds it to the LoginModel but I want it in the MainModel. Is there any way to have set() look up the parent chain and only set if defined on data{}? I can do a viewModel.getParent().set() but then I need to know how far up it is which could cause problems if hierarchy changes.
    I believe you need to know the model on which to set the value because JavaScript prototype chain is used to provide value inheritance.

Similar Threads

  1. [OPEN] Child viewModel saves undeclared bind attributes on root viewmodel
    By robboerman in forum Ext JS 6.x Bugs
    Replies: 3
    Last Post: 12 Sep 2017, 2:31 AM
  2. Replies: 5
    Last Post: 4 Feb 2015, 11:39 AM
  3. Replies: 2
    Last Post: 1 Feb 2015, 4:04 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
  •