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

Thread: Is this a bug or the way it will always work?

  1. #1
    Ext User deanna's Avatar
    Join Date
    Aug 2007
    Location
    Alabama
    Posts
    306

    Default Is this a bug or the way it will always work?

    When creating a component by using xtypes in a config. If the component has other xtypes in its item list it fails. You have to fix that in the initComponent function. I think it has something to do with the items being applied to a prototype and not the object (or visa versa). Is this every going to be changed? It seems like a bug. But at least could we have the usage rules spelled out if it is going to stay. I would like a way I could create a complex object with nested xtypes and it just instantiate without me having to break it up into part config and the rest initComponent.

  2. #2
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    I don't understand.

    This works:

    Code:
    new Ext.Panel({
        title: 'Test',
        height: 400,
        width: 600,
        layout: 'fit',
        renderTo: document.body,
        items: {
            xtype: 'form',
            items: {
                xtype: 'textfield',
                fieldLabel: 'Xtype is textfield'
            }
        }
    });
    So does this:

    Code:
    Ext.ComponentMgr.create({
        xtype: 'panel',
        title: 'Test',
        height: 400,
        width: 600,
        layout: 'fit',
        renderTo: document.body,
        items: {
            xtype: 'form',
            items: {
                xtype: 'textfield',
                fieldLabel: 'Xtype is textfield'
            }
        }
    });
    And with an existing Panel, so does this:

    Code:
    p.add({
        xtype: 'form',
        autoHeight: true,
        autoWidth: true,
        items: {
            xtype: 'textfield',
            fieldLabel: 'Xtype is textfield'
        }
    });
    p.doLayout();

  3. #3
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    Hmmm.... am I imagining it, or am I detecting the sulphurous whiff of extend-to-configure?

  4. #4
    Ext User deanna's Avatar
    Join Date
    Aug 2007
    Location
    Alabama
    Posts
    306

    Default

    What is extend-to-configure. And whats it doing with all that sulfur.

    An example where it doesn't work. If you have xtype 'type1' , and it has an item xtype 'type2' and you set up a view port and user xtype 'type1' then you get and error saying something about invalid type in items on add.

  5. #5
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    OK, I check out where the precise nature of a programming error is "it says something about".

    It's debuggable.

  6. #6
    Ext User deanna's Avatar
    Join Date
    Aug 2007
    Location
    Alabama
    Posts
    306

    Default

    Animal, this is a known bug/feature. The solution to it as defining items in initComponent has been posted in the forums before. There it was stated something about items in config were being applied to prototype and not object. I would have to experiment to find the exact rules that cause it. But I know under some conditions it works and others it doesn't.

    I'm not over extending objects/classes. I have in my current project 4 or 5 extensions for specific reusable functionality, but I use those extensions a lot. I always use the simplest class I can to base any element from, and the current project has hundreds of elements with only 4 or 5 extension.

    I'm not asking for a solution to the problem because there is one and it has been posted, declare items in initComponent. I'm asking if this is going to be fixed or remain the way it is. There is also a specific reason I want to know this, I'm not just bitching randomly about some part that isn't working right. I want to be able to send back config blocks from the server to define components, and some of these top level components are 3 or 4 levels deep with nested items. I need to be able to decide (for some interfaces classes I'm working on for zendx_extjs) if I have to play the initComponent game when sending those down or not. (and that makes sending a config down a bit more involved)

    Here is one of the threads it was discussed http://extjs.com/forum/showthread.php?t=33767

    So the question is, is it a bug or a feature?

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

    Default

    You haven't posted any code, it's difficult to understand what you're saying here without an example. As you mentioned, you can't put items in the object prototype because they will be shared across all instances. However this:

    An example where it doesn't work. If you have xtype 'type1' , and it has an item xtype 'type2' and you set up a view port and user xtype 'type1' then you get and error saying something about invalid type in items on add.
    Doesn't really make much sense.
    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.

  8. #8
    Ext User deanna's Avatar
    Join Date
    Aug 2007
    Location
    Alabama
    Posts
    306

    Default

    If you need I can post some code. But it seems to have been a KNOWN bug for a long long time. Others have posted code, as in that post I linked. I'm wasn't trying to report on a new bug, but I ran into it a few times with extjs 3.0 and wondered if it was going to be fixed soon (like before 3.0 launches)

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

    Default

    The behaviour will always be like that.

    Anything you put in extend gets added directly to the object prototype.
    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.

  10. #10
    Ext User deanna's Avatar
    Join Date
    Aug 2007
    Location
    Alabama
    Posts
    306

    Default

    Okay, thanks. I'll write my interface around using Ext.ComponentMgr.create then. That doesn't seem to have the same problems.

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
  •