Results 1 to 4 of 4

Thread: Two viewModels in one

  1. #1
    Sencha User
    Join Date
    Dec 2017
    Posts
    7

    Default Two viewModels in one

    Hello. I have two view and two viewModel for this, but one view required to use methods from another view for loading store, to avoid code duplication. Is there possible to union this viewModels, how to realise this, what errors can be arise and how to avoid it?

  2. #2
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,256
    Answers
    759

    Default

    It's difficult to say without knowing the details.

    Are subclassing or mixins appropriate?
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  3. #3
    Sencha User
    Join Date
    Dec 2017
    Posts
    7

    Default

    Quote Originally Posted by evant View Post
    It's difficult to say without knowing the details.

    Are subclassing or mixins appropriate?
    There are two classes in one package.
    I defined is as:
    Code:
    'MyApp.view.cud.userevent.View'
    and
    Code:
    'MyApp.view.cud.criticalevents.View'
    P.S. I hope that I understood you correctly and my answer is right.

  4. #4

    Default

    Wouldn't it be better (like evant said) to move the common logic from the view to some kind of controller on the level of
    Code:
    MyApp.view.cud.EventController
    and define a ViewModel on this level like
    Code:
    MyApp.view.cud.EventViewModel
    , then building some kind of container around those both views and place ... .userevent.View and ... .criticalevents.View in the items section of the container, as shown in this fiddle https://fiddle.sencha.com/#view/editor&fiddle/2aq5. After that you can add methods to the controller for highlighting, filtering or other stuff by binding listeners to the desired events like shown for the rowclick ?!

Similar Threads

  1. [FIXED] Inconsistent inheritance behavior for ViewModels
    By JoraRst in forum Ext JS 6.x Bugs
    Replies: 8
    Last Post: 31 May 2017, 3:00 PM
  2. HasMany associations with ViewModels
    By Matt_A in forum Ext JS 6.x Q&A
    Replies: 2
    Last Post: 15 Sep 2016, 12:27 AM
  3. Replies: 2
    Last Post: 26 Jan 2015, 7:18 AM

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
  •