Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: [CLOSED] [3.??] Ext.getCmp() bug with ComboBoxes

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User mschwartz's Avatar
    Join Date
    Nov 2008
    Location
    San Diego, Peoples' Republic of California
    Posts
    2,061
    Vote Rating
    19
      0  

    Default [UNREPRO] [3.??] Ext.getCmp() bug with ComboBoxes

    I create a ComboBox either by xtype or by new Ext.form.Combo(), with id: 'some_unique_id'.

    At create time using Ext.form.Combo(), I examine the object returned, and it sure does appear to be a ComboBox.

    However, in an event handler, I do:
    var cmp = Ext.getCmp('some_unique_id');

    Examine the object returned, and it's something else, a child of the combo:
    cmp.id: 'some-unique-id'
    cmp.dom.className: 'x-form-text x-form-field'
    cmp.dom.nodeName: "INPUT"

    &c

    The problem is, this cmp returned has no markInvalid() method, but the one returned by the construction does.

  2. #2
    Sencha User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    18,968
    Vote Rating
    931
      0  

    Default

    Can you post the console.logs() for both upon construction and using getCmp?
    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 mschwartz's Avatar
    Join Date
    Nov 2008
    Location
    San Diego, Peoples' Republic of California
    Posts
    2,061
    Vote Rating
    19
      0  

    Default

    Can you clarify the question?

    There are no console.log() calls in the code that I know of. I'm setting breakpoints with firebug and examining what getCmp() returns if I use an xtype construction and examining the variable if I construct with the new operator. I posted what I see in my first post, when I do getCmp(). Using the new construction, I get a variable pointing at a valid combo that I can call markInvalid() on just fine.

    To be more clear...

    Code:
    var form = new Ext.form.FormPanel({
    ...
      {
         xtype: 'combo',
         id: 'unique_id',
         ...
       }
    ...
    });
    
    var combo = Ext.getCmp('unique_id');

    combo points at something not a combo.

    Examine the object returned, and it's something else, a child of the combo:
    cmp.id: 'some-unique-id'
    cmp.dom.className: 'x-form-text x-form-field'
    cmp.dom.nodeName: "INPUT"
    (has no markInvalid method)

    If I do this instead:

    Code:
    var combo = new Ext.form.ComboBox({
       ...
    });
    var form = new Ext.form.FormPanel({
      ...
      items: [
        combo
        ...
      ]
    });
    combo points at a valid combo box.
    (has a markInvalid method)

  4. #4
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Redwood City
    Posts
    30,756
    Vote Rating
    81
      0  

    Default

    To debug, add an interceptor to Ext.ComponentMgr.register and break or alert if something ever overrides that id with some other object
    Longtime Sencha engineer. Now surplus to requirements apparently...

  5. #5
    Sencha User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    18,968
    Vote Rating
    931
      0  

    Default

    Definitely cannot reproduce this:

    Code:
    Ext.onReady(function() {
        var cmb = new Ext.form.ComboBox({
            triggerAction: 'all',
            id: 'foo',
            store: [1, 2, 3],
            renderTo: document.body
        });
        
        var x = Ext.getCmp('foo');
        console.log(cmb == x);
    });
    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.

  6. #6
    Sencha User mschwartz's Avatar
    Join Date
    Nov 2008
    Location
    San Diego, Peoples' Republic of California
    Posts
    2,061
    Vote Rating
    19
      0  

    Default

    You using rc1?

  7. #7
    Sencha User aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,488
    Vote Rating
    147
      0  

    Default

    Tried to reproduce this in several different variants under the latest SVN and was unable to reproduce it.
    Aaron Conran
    @aconran

  8. #8
    Sencha User mschwartz's Avatar
    Join Date
    Nov 2008
    Location
    San Diego, Peoples' Republic of California
    Posts
    2,061
    Vote Rating
    19
      0  

    Default

    Quote Originally Posted by evant View Post
    Definitely cannot reproduce this:

    Code:
    Ext.onReady(function() {
        var cmb = new Ext.form.ComboBox({
            triggerAction: 'all',
            id: 'foo',
            store: [1, 2, 3],
            renderTo: document.body
        });
        
        var x = Ext.getCmp('foo');
        console.log(cmb == x);
    });
    That's not the case that fails for me.

    More like:

    Code:
    var form = new Ext.form.FormPanel({
      items: [
        {
          xtype: 'combo',
          id: 'foo',
          ... (other options)
         }
      ],
      tbar: new Ext.Toolbar({
        items: [
          {
            text: 'click me',
            handler: function() {
              console.dir(Ext.getCmp('foo')); // not a combo for me
            }
          }
        ]
      })
    });

  9. #9
    Sencha User aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,488
    Vote Rating
    147
      0  

    Default

    Tried again with something similar to what you posted and was unable to reproduce. Can you zip up your version and send it to me and/or put it in a hosted environment i can debug?
    Aaron Conran
    @aconran

  10. #10
    Sencha User mschwartz's Avatar
    Join Date
    Nov 2008
    Location
    San Diego, Peoples' Republic of California
    Posts
    2,061
    Vote Rating
    19
      0  

    Default

    I wish it were easy to do. My app is 17,000 lines of javascript and extracting just a piece of it isn't trivial. I'm also not at liberty to show the app, I'd need permission to do that.

    I can be more specific.

    The button is in the fbar of a dialog window, not a tbar. I thought maybe the tbar button would do the trick.

    A snippet of the code making the combo:

    Code:
                    {
                        xtype: 'combo',
                        id: 'datasource-' + id,
                        fieldLabel: 'Data Source',
                        store: this.tablestore,
                        valueField: 'nodeid',
                        displayField: 'title',
                        msgTarget: 'side',
                        listeners: {
                            render: function() {
                                this.store.on('load', function() {
                                    this.setValue(p.datasource || 'Choose Table');
                                }, this);
                                this.store.load();
                            }
                        }
                    }
    The snippet of code doing the getCmp():

    Code:
                var cmp = Ext.getCmp('datasource-'+id);
                if (cmp.getValue() == 'Choose Table') {
                    cmp.markInvalid('You must choose a data source');  // firebug stops here, cmp.markInvalid is undefined
                    valid = false;
                }
    id is a unique number.

Page 1 of 2 12 LastLast

Posting Permissions

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