Results 1 to 3 of 3

Thread: Ext.app.ViewModel -> getStore()

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,751

    Default Ext.app.ViewModel -> getStore()

    Hi guys,

    when using ViewModels, you can call getData() / get() to get all attributes including the ones on all parent levels.
    In case you call getStore(), you will only get the stores on this vm level (parent levels are excluded).

    Imo, this seems inconsistent (tested with version 6.0.2).

    I created the following override:
    Code:
    Ext.define('Ext.overrides.app.ViewModel', {
        override: 'Ext.app.ViewModel',
    
        getStore: function(key) {
            var me    = this,
                store = me.callOverridden(arguments),
                vm    = me,
                parentVM;
    
            while (!store) {
                parentVM = vm.getParent();
    
                if (!parentVM) {
                    return store;
                }
    
                vm    = parentVM;
                store = me.callOverridden.call(vm, arguments);
            }
    
            return store;
        }
    });
    It would be very much appreciated to include it into the framework!
    Best regards
    Tobias Uhlig

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

    Default

    Why call getStore vs get(), which has that behaviour?
    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 tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,751

    Default

    Hi Evan,

    imagine a really big app with lots of nested views and vms, Calling getStore() guarantees that the value I get back is a store, otherwise it could be any kind of variable defined in any of the top levels and I would manually need to check if it is a store instance or not.
    Best regards
    Tobias Uhlig

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
  •