Results 1 to 2 of 2

Thread: Problems with lookupReference in ViewController.init()

  1. #1
    Ext JS Premium Member tangix's Avatar
    Join Date
    Mar 2010
    Location
    Stockholm, Sweden
    Posts
    735
    Answers
    10

    Default Answered: Problems with lookupReference in ViewController.init()

    (Disclaimer: I have tried this in a fiddle but cannot get it to produce the error)
    OK, maybe I am pushing some limits here, but...
    In a fairly complex view created with Ext JS 6.7 modern I run into strange issues when trying to setup a selectfield's store from a VC's init() method.
    The code I am trying to execute is:
    Code:
    Ext.define('CopcalcApp.desktop.src.view.heatingperiod.HeatingPeriodController', {
        extend: 'Ext.app.ViewController',
        alias: 'controller.heatingperiod',
    
    
        /**
         * Called when the view is created
         */
        init: function() {
            var store = [];
            var m = Ext.Date.monthNames;
            for (var i = 0; i < 12; i++) {
                store.push({ m: (i + 1), name: m[i].substr(0, 3)});
            }
    
             this.lookupReference('fran').setStore(store);
        }
    });
    The reference 'fran' is from the view controlled by the ViewController.

    This fails in with errors such as (the "vp_antal"is an input field in a completely different part of the layout but the name of the field changes randomly).
    Code:
    Ext.mixin.Container.attachNameRef(): Duplicate name: "vp_antal" on ext-formpanel-1 between ext-myspinnerfield-19 and ext-myspinnerfield-19
    if I leave the code for lookupReference() in. If not, all is well.

    So, I have (temporarily?) solved this by wrapping the code in Ext.defer with a 1ms delay before firing and then it works...
    Is this dangerous coding? Is there a better way?

    Thanks,
    /Mattias

  2. I worked around this by changing the combobox to have a store in the VM setting the data in the store of the VM.

  3. #2
    Ext JS Premium Member tangix's Avatar
    Join Date
    Mar 2010
    Location
    Stockholm, Sweden
    Posts
    735
    Answers
    10

    Default

    I worked around this by changing the combobox to have a store in the VM setting the data in the store of the VM.

Posting Permissions

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