Results 1 to 6 of 6

Thread: Application scoped store versus combobox's ChainedStore

  1. #1
    Sencha Premium User
    Join Date
    Feb 2011
    Location
    Cambridge, MA
    Posts
    1,295
    Answers
    16

    Default Answered: Application scoped store versus combobox's ChainedStore

    I'm wondering if I miss something or the combobox is still not using a chained store by default.

    In all previous Ext JS applications I have worked on before Ext JS 5, the main issue with application scoped store, so singleton store, often introduced by MVC, is that combobox filtering via the autocomplete was impacting the singleton store.

    It seems I still have to do something more than setting the storeid when I declare the config of a combobox.

    Is it possible to have combobox by default to use a chained store? Or an extra parameter to enable this via its config?

    Right now, it seems I have to do something like:
    Code:
    {
      xtype: 'combo',
      store: new ChainedStore({
          source: 'myStoreId'
    })
    }

  2. It's not reflected in the docs, but the source can be the id of a global store:

    Code:
    store: {
        type: 'chained',
        source: 'someFoo'
    }
    I've just fixed this in the docs.

    A ViewModel is not a requirement to use a chained store.

  3. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997

    Default

    The way that is meant to use a chained store is via a view model. Here is a simple example:

    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  4. #3
    Sencha Premium User
    Join Date
    Feb 2011
    Location
    Cambridge, MA
    Posts
    1,295
    Answers
    16

    Default

    I see, chained store probably showed as needed when binding prototypes were coded.

    Even if I introduce viewmodel in my application (so that I can use it to bind my combobox), its not clear how a viewmodel can reuse a singleton store registered via Ext JS 4 MVC style.

    I have read the code of viewmodel at: http://docs.sencha.com/extjs/5.0.0/a...-app-ViewModel

    It's calling Ext.Factory.store via ViewModel.createStore but Ext.Factory.store is not documented in the help and hard to find in the code...

    Code:
    createStore: function(key, cfg, listeners, binding) {
                var session = this.getSession(),
                    store;
    
    
                cfg = Ext.apply({}, cfg);
                if (cfg.session) {
                    cfg.session = session;
                }
                if (cfg.source) {
                    cfg.type = cfg.type || 'chained';
                }
                // Restore the listeners from applyStores here
                cfg.listeners = listeners;
                store = Ext.Factory.store(cfg);
                store.$binding = binding;
                this.setupStore(store, key);
            }
    I think the oddest thing is that all example of ViewModel with stores are all inline stores, in practice it's rare a complex application use inline, see http://docs.sencha.com/extjs/5.0.0/a...del-cfg-stores

    In any case, my original use case should be supported, but I understand that was not yet considered.

  5. #4
    Sencha Premium User
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,258
    Answers
    759

    Default

    It's not reflected in the docs, but the source can be the id of a global store:

    Code:
    store: {
        type: 'chained',
        source: 'someFoo'
    }
    I've just fixed this in the docs.

    A ViewModel is not a requirement to use a chained store.

  6. #5
    Sencha Premium User
    Join Date
    Feb 2011
    Location
    Cambridge, MA
    Posts
    1,295
    Answers
    16

    Default

    It's seems all new projects I work on end-up to do the same mistakes with combo box. We end-up with an application that have more than one instance of the same looking combobox, like yes/no. To be efficient, we create a singleton store to represent yes/no. Of course, we always have case where the list is way longer... Then we bind the same store to many comboboxes, unexpectedly, and I think it's the important part of this discussion, the combobox may apply filter to the singleton store, which impact all the other screens. No one expect that combobox option like typeAhead will 'manipulate' the singleton store (by applying filter). So I think the best design would be that by default the combobox introduce itself a chained store.

  7. #6
    Sencha Premium User
    Join Date
    Feb 2011
    Location
    Cambridge, MA
    Posts
    1,295
    Answers
    16

    Default

    We now have an enhancement request for this -> EXTJS-22645

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
  •